{"_id":"streamr-client","_rev":"366-bdbd0e2904325638a70c5c5451043aae","name":"streamr-client","dist-tags":{"beta":"8.3.0-beta.1","latest":"8.5.5","nolit":"8.5.5-nolit.1","internal":"0.0.1-tatum.8","pretestnet":"100.0.0-pretestnet.6","testnet-one":"100.0.0-testnet-one.4","testnet-two":"100.0.0-testnet-two.4","testnet-three":"100.0.0-testnet-three.6"},"versions":{"0.8.0":{"name":"streamr-client","version":"0.8.0","author":"","license":"","_id":"streamr-client@0.8.0","maintainers":[{"name":"streamr","email":"contact@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c85a0e992ca626c2b071d745c7af3186865f3fb7","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.8.0.tgz","integrity":"sha512-UBqh9e3j+X/ze6CGzD3XU1Xcy8RZFPIjp856sGMTKKKq84HVroXmLXGUfe8IdCDRU3c2AkLRUt/bvkN3sgtVgg==","signatures":[{"sig":"MEQCIAx4PvkuEcULEuFmptF0vimqDEMXTA6cVvbaKBMI4MTnAiA3f47lQhwOacGo1z89+VJynWTpyjUiDeQrWxvUKIQWvA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"streamr-client.js","_from":".","_shasum":"c85a0e992ca626c2b071d745c7af3186865f3fb7","gitHead":"ac05da187da28fead2644f63c9b827f1280f0b82","scripts":{"test":"mocha test"},"_npmUser":{"name":"streamr","email":"contact@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"3.5.2","description":"JS client for subscribing to Streamr streams","directories":{"test":"test"},"_nodeVersion":"0.12.0","dependencies":{"debug":"*","socket.io-client":"1.3.7"},"devDependencies":{"mocha":"*","mockery":"*","eventemitter2":"*"}},"0.8.1":{"name":"streamr-client","version":"0.8.1","author":"","license":"","_id":"streamr-client@0.8.1","maintainers":[{"name":"streamr","email":"contact@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"388733f3469eae09818bc206632ba18879f15bfe","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.8.1.tgz","integrity":"sha512-Nm9k78ErHgVzSJMoQ/vywF/hL0sMwmU71deHsulmJLXHJA1uCJHOfPSIo0qBzxc+yveZal9VNLQ5GPj4ZTiR3A==","signatures":[{"sig":"MEQCIEufqIkFKZX7yeLWzqigaMmWoz8MRict+5x5poDjiQ6JAiAgZczawsgs4hgOrA5FORIgSlKhAtt2cbzDOP6+T15wDQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"streamr-client.js","_from":".","_shasum":"388733f3469eae09818bc206632ba18879f15bfe","scripts":{"test":"mocha test"},"_npmUser":{"name":"streamr","email":"contact@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"3.6.0","description":"JS client for subscribing to Streamr streams","directories":{"test":"test"},"_nodeVersion":"5.7.1","dependencies":{"debug":"*","socket.io-client":"1.3.7"},"devDependencies":{"mocha":"*","mockery":"*","eventemitter2":"*"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client-0.8.1.tgz_1461231390028_0.7935720786917955","host":"packages-16-east.internal.npmjs.com"}},"0.9.0":{"name":"streamr-client","version":"0.9.0","author":"","license":"","_id":"streamr-client@0.9.0","maintainers":[{"name":"streamr","email":"contact@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5a33513a0cce9a5e471bda610314bea94d2be770","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.9.0.tgz","integrity":"sha512-guAsrdRCeYDL2GQbzQSNYqIFh76UuOW3/jPrw1KbFMjY7IoQhLaofz79BeK/IknGvKHZDojLYZ6q23wf21bVnQ==","signatures":[{"sig":"MEUCIFTHxnqROfsNvBvmvDS8SlAC4dBmoUOs0YrNqROTO6JeAiEA8klQvjprvHl59jTxo4wY4RcpmdXRMK0vHodLpWyauyY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"streamr-client.js","_from":".","_shasum":"5a33513a0cce9a5e471bda610314bea94d2be770","gitHead":"fbe3994bb3b02fed7372b630d1a55e538bac0469","scripts":{"test":"mocha test"},"_npmUser":{"name":"streamr","email":"contact@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"3.10.10","description":"JS client for subscribing to Streamr streams","directories":{"test":"test"},"_nodeVersion":"6.9.3","dependencies":{"debug":"*","eventemitter3":"*"},"devDependencies":{"mocha":"*","sinon":"^1.17.5","mockery":"*"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client-0.9.0.tgz_1491814559174_0.941412145504728","host":"packages-18-east.internal.npmjs.com"}},"0.9.1":{"name":"streamr-client","version":"0.9.1","author":"","license":"","_id":"streamr-client@0.9.1","maintainers":[{"name":"streamr","email":"contact@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1603753bbb13175380c7257affcbc1a08577dbd2","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.9.1.tgz","integrity":"sha512-evdGF8Ndpu9YLGkfiqgJOT/xFGLRKO7+TlSSQP5TxBc8xyczqMyKA0/aj8dGVc7iXC3dz6a0+GtmE7cqZaPLtQ==","signatures":[{"sig":"MEUCID+xcaYzHIP/rDbpLgA6V19yvc4mIHKzwditk7Khzk2YAiEAiA3hnSEacNJfOnUq67sBSH8OqB28c9JlwiZjVC0h9vU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"streamr-client.js","_from":".","_shasum":"1603753bbb13175380c7257affcbc1a08577dbd2","scripts":{"test":"mocha test"},"_npmUser":{"name":"streamr","email":"contact@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"3.10.10","description":"JS client for subscribing to Streamr streams","directories":{"test":"test"},"_nodeVersion":"6.9.3","dependencies":{"debug":"*","eventemitter3":"*"},"devDependencies":{"mocha":"*","sinon":"^1.17.5","mockery":"*"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client-0.9.1.tgz_1491837627560_0.5542124267667532","host":"packages-18-east.internal.npmjs.com"}},"0.9.2":{"name":"streamr-client","version":"0.9.2","author":"","license":"","_id":"streamr-client@0.9.2","maintainers":[{"name":"streamr","email":"contact@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"28f32ebd8117b16d605f30573298b975cba3e920","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.9.2.tgz","integrity":"sha512-L+I4k4ZeJ31AUVhQ8dpbd7momX+9QiI9IFJ4hR79O2dwISBjXkjZMIjuRT1+iHgRoseTyMsnjwvvj6oi382VyQ==","signatures":[{"sig":"MEUCIBESVA1YgmmVgk5p9y1U/lmylrorN9g2HMJB9bShO8pMAiEAg8WKLDM596L7tdYhKwKBD1YjpaN5hK+EAXNkIG6HypI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"streamr-client.js","_from":".","_shasum":"28f32ebd8117b16d605f30573298b975cba3e920","gitHead":"4a23c7a71e11056642c3eb18604c644e78bc4ef9","scripts":{"test":"mocha test"},"_npmUser":{"name":"streamr","email":"contact@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"3.10.10","description":"JS client for subscribing to Streamr streams","directories":{"test":"test"},"_nodeVersion":"6.9.4","dependencies":{"ws":"^3.0.0","debug":"*","eventemitter3":"*"},"devDependencies":{"mocha":"*","sinon":"^1.17.5","mockery":"*"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client-0.9.2.tgz_1500131180440_0.9348615922499448","host":"s3://npm-registry-packages"}},"0.9.3":{"name":"streamr-client","version":"0.9.3","author":"","license":"","_id":"streamr-client@0.9.3","maintainers":[{"name":"streamr","email":"contact@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"16e16bff7ed2f35a3106c8f06b70e77b8de30eca","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.9.3.tgz","integrity":"sha512-Ua//6+4tB7HoJSSg8BYK5gp2iU6GBwf7EhHhMgJtMRuZ4ig/gwt0CRt0sMng1d8oJgkSUmpASwNHR44cUeXXYw==","signatures":[{"sig":"MEQCIAHGm3SgrEzFDxId1fL99aQWSRHtLH5ak8AMIRb6Q+rnAiAMFLjY2GnZO4tbUxZmvwF6dsTKjCDewKWsfoSwrGVJvg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"streamr-client.js","_from":".","_shasum":"16e16bff7ed2f35a3106c8f06b70e77b8de30eca","gitHead":"0da7acdfdb36636132db310c37a9f53059327a39","scripts":{"test":"mocha test"},"_npmUser":{"name":"streamr","email":"contact@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"3.10.10","description":"JS client for subscribing to Streamr streams","directories":{"test":"test"},"_nodeVersion":"6.9.4","dependencies":{"ws":"^3.0.0","debug":"*","eventemitter3":"*"},"devDependencies":{"mocha":"*","sinon":"^1.17.5","mockery":"*"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client-0.9.3.tgz_1500200565416_0.8806379216257483","host":"s3://npm-registry-packages"}},"0.10.0":{"name":"streamr-client","version":"0.10.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.10.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"streamr-dev","email":"contact@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3e6edf7c9eeba845cdcfe7611b72b1ab20955c88","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.10.0.tgz","fileCount":23,"integrity":"sha512-tW5Nd+NE3OVwT8gbb2zeQy0d396oyKqGVHnbE8V3TF+J3PtRkzrphO2vX7wN3cAVb/+EsAYOqhMKneK1YCQ1FQ==","signatures":[{"sig":"MEUCIAuiBvBYKCF6/5R00BVAXG5R8HHqgK8WZv/Ab2iOE/6nAiEAzPX0i45JhZmb9vAFqrwWPnjqureEtrjeD0OTIenwmAA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":146599},"main":"src/index.js","browser":{"ws":"./src/shim/ws.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"80bfc39a9254f42d1ac276d55e326f6502dbb48a","scripts":{"dev":"webpack --progress --colors --watch --env dev","test":"npm run test-unit && npm run test-integration","build":"webpack --env dev && webpack --env prod && npm run test","test-unit":"mocha --require babel-core/register --colors --recursive ./test/unit","test:watch":"mocha --require babel-core/register --colors -w --recursive ./test","test-integration":"mocha --require babel-core/register --colors --recursive ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","yargs":"^10.0.3","eslint":"^4.19.1","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.5","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.10.0_1523536315193_0.08941511951797887","host":"s3://npm-registry-packages"}},"0.10.1":{"name":"streamr-client","version":"0.10.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.10.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"streamr-dev","email":"contact@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1c17f77d3d95ff6367fab103ae0784360919ce4a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.10.1.tgz","fileCount":28,"integrity":"sha512-IxJoKW6u9oiOmjVfl8a4UMy2gHX9CfiidlxlWM3cEBtLu7UtCK/AXAOwp83JG5/eDmQmP6sCcJMYgmIbLvCp6w==","signatures":[{"sig":"MEUCIQCEWsMyvxN3L1MVf50gy1G0a9Tv+4hVlfx+ogUTaNFfTAIgOUVFW1bUAS6UtnyGnPg1ESsnrSQn1FJj5wYeZZdYY5Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":638791,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa10/JCRA9TVsSAnZWagAAUXMP/ijMTi5bryxZGEeeCVtr\nX8tz3aXdQEyrpVNc3+f/g1yAqypC1CYS5/yPQP0WHZ7HFIgt8jd1SQk0DWgC\nKfconILt9lsRMqlP398weicdm70WMNZ29E1vXw76Yn4XUpUOEAMrepwAkwiI\nGmxZeTnJuPSD91km/8K/25o9xQrNs0q3obaZK6a/H4i7qObhIJ8est521kHN\naB+CWjnaoqPnRXwJGXodvcv0+ZEkLxUEelfQd6i4AUFwIzF8nad6s2c8DAVO\nqcBOwlvv6En4apO2EKX0/gKoiXhASMPMEp9+8wkWQMl0WukNlCqX7iaAND3s\nX6/bwvXNpJuMyqVvus4rtDgcILYrgdHS8JjmryjEAnR8Am8rduZAh/IcIsI4\nx7ccWIuU/iauA8lCF0/706vYS0xj3/Ka3GRwy4rVQB4M3STiCrbjezpOJ66V\nRLVrnpfMftf4h/YV5ssqEYINY7n+9Jyg6xGLM9WhiyIVE9QHLlQJyp7iqqBU\nImGt9ZWi45M36JKLBSGanVDErxoqqmGlUmkYsNNy+pqYqdCAmtuf+BosALLF\nqcRar9GzTVedYHmkBdfSkFcsLfTv+UpE2TRJAUlwefX7Z7Zif4GYsslUKZ/Y\nToNgL5pHyXpe7r5p9dxKaNip3aRrZSq/IEVSRYFZ26KM0pOKwCotwpbJUJqA\ncZ/u\r\n=4nji\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","browser":{"ws":"./src/shim/ws.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"fc54d2cd4967ab3bc7221bdc97d9f535c68da92e","scripts":{"dev":"webpack --progress --colors --watch --env dev","test":"npm run test-unit && npm run test-integration","build":"webpack --env dev && webpack --env prod && npm run test","test-unit":"mocha --require babel-core/register --colors --recursive ./test/unit","test:watch":"mocha --require babel-core/register --colors -w --recursive ./test","test-integration":"mocha --require babel-core/register --colors --recursive ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","yargs":"^10.0.3","eslint":"^4.19.1","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.5","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.10.1_1524060104925_0.31099495907903596","host":"s3://npm-registry-packages"}},"0.10.2":{"name":"streamr-client","version":"0.10.2","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.10.2","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"streamr-dev","email":"contact@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"61b3ba8b2e055b30956f32c9d58f7950cf404d85","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.10.2.tgz","fileCount":28,"integrity":"sha512-BWpLF2C7nMukAG2QvDzBDHg12aLgaHCJ9gYMwCX13q6Ac9QT3D3ONfWpRfFK4S02yrPQsNg7QaVJhscdgk6EIg==","signatures":[{"sig":"MEYCIQCGWqMctktV/YONBg96ATE6gD/kLyZpKlBI72JrDbfGrQIhAK7X8oN92GaGwAro30ZMzagBibXjGkfFh4AN1OAeugYK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1219401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa6GZNCRA9TVsSAnZWagAAZyUP/0uyodaNtdJmAfRKDlVx\nus6yA0B6OUdm4I7Xc95JiX/TQNnL/xREvcYE3xg7MXzmHQeiLNK6Gtd8P+m2\ncjBaGj/V0gCp27FqNSZ1HyEwnWP3qpteTIYcOtsK2Mm8bSDInXBLj0WG6NG0\nHDTNI3Wi1NnQW2ix53vaYbnpoFO9vtMCYOOy893AI+YMb8oPUxrwKh2LaZk4\n1DqmugCLGt+/oA4vlPsUwKGe4Mv69jlJ3ZTrNnupvJnbrSW56Jd6NucId0Ck\nHJlsqKaEQ7mYKlEZOMqPmg8SBsKZs9OtLVq3FSq8ZeiNwrt3JZs2H39WaPam\nVTXx96DAlA87tgWxDrVFxiTbgA6kutXBWUbJnCr20jezBIQTVhBtZB2Cx2xs\nLQZXdylNE/1WtKOciM0PVKO85YWK6i9zKjLFfE+jicju9OjI/Ht3ByLOlD/G\neYdqo0gZ/HRPEEGo1fkvimwFrs04UVFJWx8HggjjX37uJxXrCxLP8HQ07ccD\nkRh0MEprCfh2d5KbXAR4lIy9SnA7tbjRwZZzZofzZfIKV35D0QQov1A2vbEX\nzBliTXdKZ7csO/bOEl+Bofg8eg4jp0KU60qCJbkm1WdMsb0XHKDMyU1AmNw0\nSA9xDoaATZkHQZKsDqYvv76jTl2ZtZ1qcgPC6M0S/GgHwl76sRuz/QiJ+Qyh\ncUiV\r\n=cFxG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","browser":{"ws":"./src/shim/ws.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"ca09a5a48eb05870cfd71b21b8446cd0dcdbd454","scripts":{"dev":"webpack --progress --colors --watch --env dev","test":"npm run test-unit && npm run test-integration","build":"webpack --env dev && webpack --env prod && npm run test","test-unit":"mocha --require babel-core/register --colors --recursive ./test/unit","test:watch":"mocha --require babel-core/register --colors -w --recursive ./test","test-integration":"mocha --require babel-core/register --colors --recursive ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","yargs":"^10.0.3","eslint":"^4.19.1","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.5","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.10.2_1525179980837_0.592072904765","host":"s3://npm-registry-packages"}},"0.10.3":{"name":"streamr-client","version":"0.10.3","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.10.3","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"streamr-dev","email":"contact@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"78abfd0ba15e956614d7b1399ac078d8e42cc620","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.10.3.tgz","fileCount":29,"integrity":"sha512-m9G4pfkOKVmfawI+WFiYrwTUgYe8DcUpaEmRTYXJsOLCw4L7934RC2/hYd5xTCq0QXjzJtXWeLBWiswu3ojZ6Q==","signatures":[{"sig":"MEQCIFFO9gf88Cwxb9GjuMkysIYrnLc2As0u5wZLYBeO6sxoAiAfOOQLmgniK4vG1xmcQITBlI6OqZTD59rkqtsyu4BTng==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1221674,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbA80UCRA9TVsSAnZWagAAPDAP/23xTWoajQMeTnBpW1A2\nCm26S483q3TMzqk7hkggmrjECNCOhIi0U2sJlDXrKVfHgt/v5d3UHA3OTa3M\n31fBxWM52Iv7AHq3ku9mT253R+9PUbyI5jT4VDShbPevx3IdMhJEMhO7/nn6\nXmNQfByk4V5ptb7K2Ob5TBKWGaGdjFbNXh7P9lsY0P1UiJsqIw1IQy95xFdI\nlXwVpQbSf00x7103gz6F+OBugCCh74Q3oVfSFZah2+M6BS8CJGnIW5gk8/lS\nGVOf1cGy2Ab05LJKrgSMu3xyqclZeAAcIvNbbGXsvecHpRsvifL+zC6S2Gaf\nXt1hsfwW3MquSqgbUzZKbqUBOplOJN7jfBl52X0GtLOaU/2kVKd2WAiTKzrw\nC3V23HgycorZXd29Z3rr3GfC68cyTe5OXo7mUfiVnllDezou+hDVVZhs7nrp\nbn9s9vHesntGw4t3kBjvGguLbgY0W1OzDZgAD/AhzhK1emEPXvRJYnRXoZ6E\nas0pe3dUn26YJfN6Tkf/S3s+L5GoMTHXLHJtGeZNNfOJyKINgf8SEWjDS818\nYUpN1UX7Cwr3HX8O9/Q50egSkc4eseiIaYWeqpT8PSJysDXdNKki0TKe2UvQ\nJjBJdkT6aEc7l8PJZJcP9zyEAhVxp6S4ETHftMUyXPok5pkc6BylGzuI2WOZ\nhEF6\r\n=o6cf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","browser":{"ws":"./src/shim/ws.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"8fcbf1a1a3ff2c2a63bd3e1cfa66882aaefb1e71","scripts":{"dev":"webpack --progress --colors --watch --env dev","test":"npm run test-unit && npm run test-integration","build":"webpack --env dev && webpack --env prod && npm run test","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"aapzu","email":"aapzu@iki.fi"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.0.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"9.11.1","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","yargs":"^10.0.3","eslint":"^4.19.1","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.5","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.10.3_1526975763638_0.9053640714641851","host":"s3://npm-registry-packages"}},"0.11.0-beta.1":{"name":"streamr-client","version":"0.11.0-beta.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.11.0-beta.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"streamr-dev","email":"contact@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"f2421f3444ed5783e3efae93c27a2c2988a47ad4","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.11.0-beta.1.tgz","fileCount":39,"integrity":"sha512-7s0NVhMtbuuvZfIAMwm38NDykh0WrjkNt4jBQZH8AQOMDi+cHwt/nSi3xC1qm96sFN/ZftTBt6tXZqQR2OuTyQ==","signatures":[{"sig":"MEUCIQDPwtw9VHFXda83n4pwTsrjeVz831EYGY1ObtRmjNBwOwIgKua8T0aRBwFaBHphbWI2iYu02r8DVd8xcmSVaYMjZNY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1352000,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbFP2RCRA9TVsSAnZWagAAM5wP/2s5CPEf1+eqxPr1jE9d\nb1bWVSFrmDodL/MFMDk86xaHUN5VjHvYeC7gWCORhkVQMjkSxcc0ft46NPzp\nzQRt2MCMieYzl8DHDACR6Aqu/XW/PACCOIge942DYHUzC36u4p1QsjmVVjsM\nTvPGmrhyQVUulNSsmklYGnmSVX7kRRkgfjYYUUfr9Ud7fSqgbLlG8xKjnB0p\nZrQVHfkEl9FHdp5vGJqh26PB0ku50zp+N0736zdD2yawDq+DCCFELRNH41r6\n/opNHLiHiBhapr6rjJ7W+B4Gpvg0m87DBPsaYbIt66COrKaIol7KcE+dMY/1\nyQMWRWdtH7GrwdIRDWTeUC/u7PSlgOAHO3NPsi2C7S4CnA8Z2RnuobGBWlDB\nrNSXcH5oOwC8kDFuwOaxT3jzLc8MebVdmyt3y/yI2y+a3rg1rcyAZMhW+Qjp\n8WCcxS4IuY8LydFF2oZr+BTBt3SILYoT2XLI2uBMrPfAkpGJ9lwls2B9u0f6\n/c4h2Q0KT7KvZuJHvR3I43kqoN73pptKYIrXv4jJqz/vZYRiTd+hp/BmrInX\nlj8hQkB/mSbQfMpCxPN0EtRUGYxI2cRw2y4VTAuYO6s9ACmTERdNKh/jDBhZ\n7KJg+h9rkh46ThUR5tEwxOzlzgl/CVTNXFOjAmyR5+Dx8wzRXUU2dgb8dpst\n6MR7\r\n=31lS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"ca05dd32a99594d98bee5732e1641fd6789b0e8b","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"aapzu","email":"aapzu@iki.fi"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.0.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"9.11.1","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.11.0-beta.1_1528102287895_0.5586536065555736","host":"s3://npm-registry-packages"}},"0.11.0":{"name":"streamr-client","version":"0.11.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.11.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"streamr-dev","email":"contact@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"66d912931ff7dd69922dd0d0201484479a928ba3","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.11.0.tgz","fileCount":39,"integrity":"sha512-vhlmsqPyBxQQ3B29uSr19Cs3BrSAGrjQajtNmouuPXifRXjZQ3xe4qVbwJtLvUM78YTWP/ux8REyxI38rg4OEA==","signatures":[{"sig":"MEYCIQCOVcdTY9CUr5zQbMwHfEMA1IUnaSKRgxrzPu2ehaAGAAIhAOjrv+F4xh/jpOsWI9nmcqPUjU4q/PcxnRQhDReQE9h+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":879829,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbHoIGCRA9TVsSAnZWagAA/rIQAIehunCAePqn7peKiQ3E\nYDg1vlZ9i43vkK1kvsS1BLwROb2J/rAglvEOFNTzzWAtC7kyXLXE1IuQbrXO\nnsehJBEhGdwuasZ57ejBLNq0TwlsFsqP8wxhbj0wNKIM6zZewsoc925+JZ3z\nzEQCAJI/vja/YOGLHm6zomiACcnKhwYFfN8au8uVh9YHBu8YtF29jNVw0SGL\n/IpgdcNqxMwnHzLI4gPfUivn5ZcuV4aNLp70xw76g6NIp/JTASkEw3gzFalJ\ntlittm8eZtj54exQK279stL8GdIoXy8EUgWE/xPMapMKpscPnnDC1ofat1Mr\ntXbySCIshynfWUDH/U2oPpoC07NkkS/kQsurzRRClOYr4jNGD+lv2bmKqKV0\nI4QZxJA/J1loxLRv8AIldaD03EG5x9eVKozMpNkAolQ3TsFPSfA9UoZkj78d\nShatsG1knbCDYCnLxmhx2YVx1AWHahvrLmPn+ag3l6gMyPvlkKHvis2rtvRw\nrq0faAYnTNzK2KpwXcYirjELQNrlbUIU7LiZ1iKMvBW2Ok85VOpF6Re9XlkV\n3pg7+EUQkRUj3pnvxTdFwMjepxvBrBhp1zJ50Sv+EISzMnpdIStSRt48mXc2\nOwliczdPt0P3/Mq7Hsv5yNUWnvSKGQFxyfiyWIE93ZXMXzLBnvhfwi34P4Gu\nOh2O\r\n=4MiY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"197336fb79ca9cbf3a567640ae528b7d9e1f32cd","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"aapzu","email":"aapzu@iki.fi"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.0.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"9.11.1","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.11.0_1528726021213_0.341845830272536","host":"s3://npm-registry-packages"}},"0.11.1":{"name":"streamr-client","version":"0.11.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.11.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5e454cd6fcca99f9cd6195b80e361c9b9ab8e254","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.11.1.tgz","fileCount":41,"integrity":"sha512-em7KG1SEGmasOQV50jTLeTMEK2iHjm1YIt+f7f61Rzr9XugdZIXmZxQsTSdKbW2KItF24NMib+MJfOCofQ1YfQ==","signatures":[{"sig":"MEQCIDPdWDnXFg2rhSTPLhmRf+lpLe7codUQDDH6t15FGzdFAiAGPwGuYVFLsFpsNVBuoyIkQ0dsl0bbkNxGxDzqvbToMQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1293269,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbaGvNCRA9TVsSAnZWagAAOR0P/A2TMJCZBNq85MbbfKY6\nrGmDxDZ5A/i6x8pnRZJjXRYzR289oLxbJbjGajX+s38tZdjj5/hWezCZrN1T\n5GtRVESdboJK8ar1ek29HzKJ7B02P0KHBSB8eqg3va8kO6SLrNWPJXqslEzO\nuFh96ycb1+XZ0xzoiUkLlBuc4lPkzqm4tWIh/xS47O1lPiudOEH7GT/cuw/L\nplhliQ4GxyAjb/QDUO3yIi8dkmu29Mv6Cmmc1eeOPqKW2Iw7RhlPAocNV/iQ\nhx0bSVFulz8zf5FeaMOHz1c0DRaCZgbABJ/Jq45AHUkv21RL0p9nLvniNYc6\nAoKxN2e1ZRRQn6ZecppOGVXJIwLMfpZv5WWLeiia4uR45k7/3+AJXvpabXxs\nj0VCNJigy+lL50r6qpaNnL4vjOcBtXspCjI6XWFjRxs2O8PwOK1kRKPtYJLD\nMQZmR3yL2hWaqF3BYcPmJV4jTtQNowW92wJX5ojXgKLogVrNhlyXyMe9hGW6\n6Q9BJawINW2maN8z5qBQRoTYWOQ5IoK7rUcPaFfGgVDGPfg7i0LKljrbDE6O\nBwQEbkkJDnGVXpvocSI/uMML60iRem4+SONdcc+zIJNdCZsYth40rYok2xIk\nTJoMLVF2RJ7/9E44h+E7uk9JClvJ1pdJqYaFUAu9adT999jPGgo5W2TCyT/I\nYOkb\r\n=p3HB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"20299f2bac0eab58f2a5d15fb3bfd9e09bd425a1","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.11.1_1533569965691_0.800338470883746","host":"s3://npm-registry-packages"}},"0.11.2":{"name":"streamr-client","version":"0.11.2","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.11.2","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"03254c3f2b31f609010dac8424f349d60b6bd555","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.11.2.tgz","fileCount":43,"integrity":"sha512-LAIFylPn5Lh3e3aHrq8dfCyIQUQiUkrR26kI7vHQlg8752BJf8AeaQgp/XqAoxIllcRvcGSdG9UQMrVDSv7YFw==","signatures":[{"sig":"MEUCIQCw60gLmdQejdnHBfF4K9pO6tS8wq5rVFMPrwj1zd0Y5AIgFbuI6oPNNJjQIjKH53udu5L0z7Jz3ChCSIky5ce0OQY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1329367,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbbJuRCRA9TVsSAnZWagAA37UP/jjAAg6HTCngRH6rMD+V\njn6tARcAKmZZxSLjbAFq+GoaJR83GtIZlovyjv/w4gCTqaz5ru9GxqwGnlED\nSoVbJfEQ/O/FlmYW3IsFpCT36W/QQ+y7iCOha7ljnq5AOCenJ1soQd/dQ620\nEdkId6RNZr/ZHXfNfiCx39CQAdgm5wS/en7Sm2f42Vcq+gx3IGXOEmfY560O\nXDrZQZbFggg9wDTYHuKkhZOuhSLZZxhelY4JbWLZTUMlumgKDxtXocaH4gtf\nO9eR0Z0Q/mbexiNpiVYvT6qSIWU36GxqUILVEEPygcVat5PGl8+b6kDEw6sI\nZG2W0POYttaFFUOrf0cnQVWnuPR+LXUf2ERnehXpqT5RE0K9jec3bmKuremE\nJAp00bFFqE2Xdgrh/QNlPlyyyA1kBlK7yfQq92Ds+/MxQqj894xigu+EB+DX\nu1l37pBR6BUDwPrKGbOZHXxhe0FnEpq1MDrgnKC04xHqOqtyjCkuDGj8+NLZ\nzo0/ylO24DihNjwGVTq/4q0uvSUccI3BTwVzSxsV9Yy++r2M+2Q/3pKDNxdz\n1f9l/DPBV8EvTBaj+4SGoLYS33L73/P4sDAuFLniYPq96TvEB2kjwcS7/f6w\nxyGC4ftvO29ZwzhuJ65zuBZGMx5V58IYCxqOxR+SHEDFlwfoCVaY49YxLryh\nxkUA\r\n=gbOC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"408c59bfa0f09465abe7cf2eade184f35c5252be","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.11.2_1533844368597_0.41959358306583927","host":"s3://npm-registry-packages"}},"0.12.0":{"name":"streamr-client","version":"0.12.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.12.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"7cc555496d5b9ee747e72cdbbb3f285bfde3b906","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.12.0.tgz","fileCount":44,"integrity":"sha512-Pf50qDqWfX0wNgyhCbfVfXtZCT7TutuCqQOwDj5fk99DgohIG75CoZ0xa3mnPyVlNluJ7YrZ7wjTB18MWtkDzg==","signatures":[{"sig":"MEQCIG9o8Ixv14FlZcCuZN26eMTWpvIQM2TqKdMwcMatCUBaAiAyU3WOq5LuQnHFDqfX0tk2Tj8GhdCjv1s1LmKKfBa3gQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1359852,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbftCNCRA9TVsSAnZWagAAvEEP/3Za+q59fBuTR1uUwdfg\nPhttU7Z5ju1huIznv0zpufWuK9XZbXhiZBjCorvrnZbttuiNdzfCR/Q6q0x/\n42Ml/gFk5ZyFCo2KG8jiY9KqJxJmkqmrlCmc9Ci/bgaJ7JtORMGca4A7lArq\ndLFfCRDfB323f1oeBKNXrDCGrzUJwF5y32LZFCtyS0C6paRrW0MzjNh52fku\nAS3LazFJIPcp37lTx5fBuPC72qBe8wEZt9f6dQLMMw1j+obFHFvy65h8YS86\n2TaKDvZufO6Pav3yPCPWcXl68HOjZoME4bEUMfRpXJRvF1udBkODsv42EK4G\nenfml9kquF+7MlgqaFqCvMrgH+30cCcCbWEU6zihWFOwx7lVu5Xnv4SLH1ac\n3dx3BuxuRlE5YjE9eNlFUw7eEeinW72AK1zmoOMtkmAsaDxnVTCwbvkFZqHA\ne+Il6mmhYjdRgM9nGOKiTEhd0rCy44CqywJohHfPx6l9kzeM1czX/JABz0W7\nLsLF+RSAkuXvpvdczUbvQ0CuEA980/l5Fzj4oYdteVA/pAYiQyh9n5y6n0cZ\nwrF9giwcjaqum8XGXnINSFRh4saQSSWn3UZWOwj5YvLVTofPNt/gqpldZdAJ\n9swxSBezSoYdfOaIa0fgyOFw1icA2R4B6ZMaU5C+SATwQ7FnMkwzxkg0MiGy\np4dO\r\n=DzXo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"37d2e1f3adb2150120ada29c93fa2080fd457d36","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.12.0_1535037581073_0.1289059352083577","host":"s3://npm-registry-packages"}},"0.12.1":{"name":"streamr-client","version":"0.12.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.12.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"752510291ce3453626d8540dbc07cb6ff91b54e1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.12.1.tgz","fileCount":45,"integrity":"sha512-r3aUx+iEN533xUw+iu90SBMa1geKNaZRbRF2b1zL1MgHsnKAuKXu/AodKq9EqPEsAtVgRv2K7xK5jwdqSdRZDg==","signatures":[{"sig":"MEUCIGtjgjQ6L3XYsXjkj0nl4/CVt3XSLR4U2WFHm+0+TiapAiEAhoQopqNcIG17M8337fKiqIoJV3i365WFmc+Pv5w6W6Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1361821,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbjEwDCRA9TVsSAnZWagAATqEQAJTbR+h0YexjV5U9aifB\nmWZg8ut3RbOfQWCidjrN62SnktoBO7Rs3w1mJxZrGKci1SS+X7YVbvVzZgwA\nVamu5e6p19Lgj0NfyMrLjAjuWAzeiAWOdnAiN9uOU3w+dnZSaQ48JYB22Wnd\n0IHNj4kqiDLBr5wLI4tvC0JcQFppaDB0cjx+8l6N+IBgiQhOpXoUASZfZehQ\nNLUC2pAM+KiysbPswEQ036dkYMu0PhdH1JuXeOH4ehoaYSkXy+RM//2E/c5T\nN4nSk8ItvFSV52m3f67Fnnsap4M4v4fSO/AzAusb57SB1rIvKlGWvGpA3q3B\nnrtK1gHI/eDus5BNTmnhVocVxUVmXtV7GLedyJbZqBFaZOre2UR8XIleferM\ncu8esx8hU9MD1RSKM1fAXKubOTXEKmo4HfPiJfHjQ72TtrnaDDKKuFu9vhZo\n1UdCc+PO3iw4D8A0P1sgzceMhDQ/xI77Nv0eJkETMR8JiiVhENvPZ5cOTd5Q\nBxy5yPauZ/Usg0EIhvgzMAOacVhPzKQWf5PXEBKQxEcq09FBW987HnvXju6z\ng9/uqKWD3AN+bygEH5m2Un1NHlQQhZJgbPfzYtgqIyX0ZS35vj/SVoSu0zNH\nIBgOXvBAYV+PJB8UmB+pd2CcIj2uR35JjXsEG2ilLZo6RwAmFpAtVlRlxImk\nf8GY\r\n=fiSO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"03d533d933459def69d75df106ccd3f1308d4a0e","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"5.5.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.12.1_1535921154327_0.8250820316177558","host":"s3://npm-registry-packages"}},"0.12.2":{"name":"streamr-client","version":"0.12.2","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@0.12.2","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9d46d6f1f533dbf92ab08dcc83d40c24e59e9cf8","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.12.2.tgz","fileCount":43,"integrity":"sha512-5DS5Cf1i1EgvH3lE+vdy33umYWioBADmyTOy5JvmnE6ZlwAiHECZCaoiXbFXc+IIxyyD4VMMFCErnIyIhQ0o5A==","signatures":[{"sig":"MEUCICLPX4pv8KzJuAYYzxLyzWg3F1P29IeS1Ytdvxt+/2V9AiEAvhDIa8UpmaOLc2fH94AT+Bz2hSRW/srnyWD6dTgrzfI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":852418,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbsiCbCRA9TVsSAnZWagAAF50P+wTQ0jJN2inr1FW0BxI8\nNMALya/fQg4uaXhiCwOnVSApeK9fwMPbb8M4SF4DuWea8znLKPZFSkeW7JSO\nyDzPIO8iUyJAeXceSfg3pqsvrUtF/anMHYacb7olHdAHhwOFO+a/kY76CD2i\n7Zz4PWVWGHrDLIogUpaPcFFCzN/hFzVCQ4V7Elsa1SBRg3x/rF9JM0Ct/+aJ\n7fRotFpttC+7AZdGka/7jeLBqvg42uaSKiulT3+RmdKZV8/YIFDPJ2i1gYJz\n33EG3B3xa2vjInaFu7j2VK2gTRqOoIgdXWgU76Eg71QdM/jsKVAoBkIxHRk0\nD5hxMDeuVUUFQLiG5RCzCNoT+V/PG1kEXgOJjlVaSVbrZQGO2bZo6WzfIrft\nKoCmW4gOzuJJo10pKyPK/jTgar8yvxlGnNwBmFYCGrIq2JK727Ng0NDLvLlD\nE2iUu5YNaVzz3OKWllIVQ6UjvsiT7z6e06axI8sbvUTPyMfLLpjPmZNLk1B7\n7v/urq9Bteq0utUaPQ+ys+vVEnymuUsnuWOPSpRfZNelXXcCuT73gHyZ4b02\nfkytxXdU87sY/w1i/1qqGZ7k9VHh3+JzggbO5iGM3mIbdCjkr5AUnXZJFz2N\nMmdUVkJdMtj1pLCA7NyRH9BgQj73ifTiqsbEVxcjPt4gXs4M49eqjix00O4L\nUudB\r\n=mP00\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"8fa9f629cf9305e62dc903f28490f2d652019ddf","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run test-unit && npm run test-integration","build":"NODE_ENV=production webpack","prepare":"npm run build","test-unit":"mocha ./test/unit","test:watch":"mocha -w ./test","test-integration":"mocha ./test/integration"},"_npmUser":{"name":"aapzu","email":"aapzu@iki.fi"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.2.0","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"9.11.1","dependencies":{"ws":"^5.1.0","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1","sinon":"^4.5.0","eslint":"^4.19.1","lodash":"^4.17.10","mockery":"^2.1.0","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.12.2_1538400410865_0.09645596131256218","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"streamr-client","version":"1.0.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@1.0.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c083d1d0a9cf69ae51f50a867dd321f4c1e19457","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-1.0.0.tgz","fileCount":53,"integrity":"sha512-KiZPLwvv3NA8zIwi3OnI5hPCe8LJgzzYM2ZCbGD6/eGz+dRaMiYimkUKdzlpItGKPj60xNChzqPDiHdXFr6XIQ==","signatures":[{"sig":"MEUCICamISugF6Jw/wMQalstCGPNIimMrbWpEOdWSO5+RdSeAiEA/Jrn2a8gkq45IWd/H9KuS8QVFgmKzAqovwjN0SmANOU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5564800,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcCEc2CRA9TVsSAnZWagAAG7cP/30PbInnaOFwjb/qP2Mo\ny5mufebsqF4/nJE5TkObL+vheGlYz0aMwMImsqEZTppS3QcJtOyE4bm3yqkU\nVaK7nq0VRGeymlY5Lb1ftBxGXhHKgG5lT6VpJgBV4VunYvKzNhOCQ/sVUCFf\nWPeUT5JZKODK62qnsBaKG20xtU2vQtR9+qp5/SYTZ1vjzi0TA1yz7DO1zylS\ntllaGAiVgp0p7l6qaZaoxdh7Rt1H5xaFY9Y9yX7nUBrOzCb0NufK077vdgzy\nqoaQWwFma59XlG3dth7rLt7g5QJIfe4n8kQvtAIDDIA+iFHRBUNCYtNAnpRx\nyalCYwSSRWSjsqrfQxMt/ErBYIlVS1UZrYG4kTgkfTb/25sMUMsc25gDqRD8\n9xI9obgb6+dsZ1XUd7uiS046pyjZZHJiPI8undpvx5WqsRgiMZl6/atYy7D3\nu3n5L+i4uRanjIGdC9maydO4jHutAUCUhFmh1eP1HuGTDgpgdMuy1DPffSlU\nTCpBTTdEF6X/1VVgUmQOMA09sAVG0a4V1VWQLNTTEdeB/gtrAK8dLAEljh9m\n4a2M0mKwETZGHlLuhlYo0kWYwSTSKOQWCnhOsctOa7VrKrBrjkAqTs+BbK0V\n4hzd1uXTDOCeNm30VdJRaEbuFmQgu3MEbK5EDLVvhBIPWolrBib4gUneioLG\nmpLb\r\n=Iy3J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"617bafb2de7a1dd41f81eb9bfef7fe8f33a72a8e","scripts":{"dev":"webpack --progress --colors --watch","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles test/unit","test-integration":"jest --detectOpenHandles --maxWorkers=2 test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^5.1.0","web3":"^1.0.0-beta.36","debug":"^3.1.0","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^1.1.0","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_1.0.0_1544046389956_0.6994180837778612","host":"s3://npm-registry-packages"}},"2.0.0-beta.1":{"name":"streamr-client","version":"2.0.0-beta.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"cf0fb2d45d726ae31b76a205a2e4a1dcba474356","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.1.tgz","fileCount":59,"integrity":"sha512-4Ntgskbi5DT4o/y10VJd078BzadHL+jEqggr3WEZCjBcylhyBOU+HEtDso2Cu5RtqRrPUgu+SwnOoKC8JUBIsQ==","signatures":[{"sig":"MEUCIEgBeeuAaSaP+PdmaFycgQgEng67/W8N0vKJI2xN38u8AiEAoNGP248fBAZ02tszh8rmpwHCNk20JPsyhxwcEvT6D0g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4476254,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcmKe5CRA9TVsSAnZWagAANf0P/0mNRjG4CMNREzoaXmlU\njh56xvkA69mHlkoEgW5u0KdBMTddvUkQScLa18u+klYFytYvUn709fr1zFBO\nis9U0HxKujjG/dQ7gqXmpg+BVow2ZOsuHbqCz/Ch3+xbwdqLOLqnOFngIa7Y\n/9dn9lIWrnjKt4uiLamAGhpPwnEyN9I1c0coVyf1YZHZhw+1XaJMTNgHc6y5\nzA7kdcTZ642Pewb4geDiHYvjHeERWhpgJpyixbYBIsI8i8EUvE9LefPtCdpx\ncQRbYOGHBmu9zHVLhO+WvJUvap4WzlML9nwnx8ZU8ILm05iqvBQkJDXw15nx\nd3TUAIPYglKpQY71X92Ae71rGXNXYxdd+gEWllumTQs8fpgB8G/SzbdnTMwn\nAdJVqu3YAgMJTMu7ov1fMl/tjNhxd/Lc1WrrEXyQzwoblgmzGYIRp+jTlPye\no/MO8AjpB27rWjCg/Vs2heH4kqF3+ZOFqsgNVRZrIB9Ld8TQlhXKnahQR4Sk\n6jz/Cgy8oVfqS1buDWsArzFws89H0rnJQHNN8jwL8+4rXoILTWAA1qRVnJoh\nQiphH32DQ75TXkfeRK02l1DkOHiwzcGUNt5QV40RxEaqr0k+iDLPqxgfHN38\nB6RjBovxp6UEpNQuYJHaK/1KzR7ApNATO+Kfa/59BTw4AsANYxnr5J8rigeU\nT3Bb\r\n=QvoT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1/ws | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\n\n### Authentication options\n\nOption | Default value | Description\n------ | ------------- | -----------\nauth.apiKey | null | Default API key to use to authenticate.\nauth.privateKey | null | Ethereum private key to use to authenticate.\nauth.provider | null | Ethereum provider used to connect to an account to use to authenticate.\nauth.username | null | Username to use to authenticate. Needs `auth.password` as well.\nauth.password | null | Password to use to authenticate. Needs `auth.username` as well.\nauth.sessionToken | null | Session token to authenticate directly without fetching a token with credentials. If the token expires, a new token cannot be retrieved.\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\nmessage  | A javascript object containing the message itself\nmetadata | Metadata for the message, for example `metadata.timestamp` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`.\ndisconnect() | Disconnects from the server, clearing all subscriptions.\npause() | Disconnects from the server without clearing subscriptions.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client \n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\napiKey   | User key or stream key that authorizes the subscription. If defined, overrides the client's `apiKey`.\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | `{ from: number }` | Fired when a subscription request is acknowledged by the server.\nunsubscribed |  | Fired when an unsubscription is acknowledged by the server.\nresending |  | Fired when the subscription starts resending.\nresent |  | Fired after `resending` when the subscription has finished resending.\nno_resend |  | Fired after `resending` in case there was nothing to resend.\nerror | Error object | Reports errors, for example problems with message content \n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"99899f1d3deb87a7c623aafa63d0de354d9f2cee","scripts":{"dev":"webpack --progress --colors --watch","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.1_1553508280586_0.6960539369946646","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"streamr-client","version":"1.0.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@1.0.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c5e3e32a82836d5bc7d22426979b419c3c5e4acf","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-1.0.1.tgz","fileCount":56,"integrity":"sha512-uStU3WH/AM5GwpiMdPMOd2z0GjsAl6T9YnKUbb6NpU6tdka8PbGR5HAwuFdD7MBXOeiNY6j1kYYRoTyD71mL3g==","signatures":[{"sig":"MEYCIQD5z3XhW4i3E4dHrE17T2A9+rQlhc/5WCeJQroOr37HYAIhAM8AEJL0ao3uSosXPBgzMV0vnny9HRwCoGwyopx7cLcU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6168234,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcmLZrCRA9TVsSAnZWagAA6jAQAIFDL0yjs7NwPYFKjMDq\nQSUmng6KKUfXftn1rsiE5oYT9zXq/ji68G/EO7F7UarQjadH4lBziuf3Kx03\n0wfZfUu0f77y44pgH8sJVmj5G37AJlrY8e6PsRF5BFDjBTISM2hoEBJZPDvk\nL/5A6fa7Fcp+IJPb6fJI810TmUxeRbCS6IaxnGxeV86CzwrXfTtBg5L1ZKbL\nBT8xZ0dWeLvhdggF+cDP3t0RbpITJd/tHP4ZAiGVAFHr86JWPtD0ZzhmYZ/X\nWcDWyvMZedLT4r0fJJYcycVXSzB+c9wQKYlOdwoFXe36LBgHNJlPxf2U4I7S\nVh8ckbrRCYMFz/0tdUi13ebLF6mOZn2GXQI/ZBFyKg4qn0CuKBDFpIaL0dGZ\n6wtACS5im1fvrJu/hR6WFq9LmwbLcovyRaDgUeoyapXbN6oKpxLmxtchG/8b\nueveVqmHI4p2Kx3+/8j90/T+Cga6ic/uIM/qm9gv/f/ff8uRF/OfLKz2SdoN\nq2bfZXs2YL6H2axBpblaOVis8BgLeW9cFtjQ6rYaTkT4b6fOd7qeLvWjJNE4\nrNatYtX9X+qWFQQqGoHotAbHXZ1SsqjD63d/Qt7Jc1erNgE1z2Nsl19TAFh9\nv+ooILk7nITfcwLeP6WkZ4I/NiWxCnDnYteW98PQ1TxZx9r+ff9aywhDbBs3\n9Dde\r\n=4k8j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"07971148671b00529a2555a7b6e73d61af88347e","scripts":{"dev":"webpack --progress --colors --watch","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^6.1.2","web3":"^1.0.0-beta.50","debug":"^3.1.0","websocket":"^1.0.28","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","web3-fake-provider":"^0.1.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^1.2.0","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_1.0.1_1553512043032_0.5044755224355173","host":"s3://npm-registry-packages"}},"2.0.0-beta.2":{"name":"streamr-client","version":"2.0.0-beta.2","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.2","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e76a4282efe235f6e9ce97742f2c066f68dab741","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.2.tgz","fileCount":59,"integrity":"sha512-lnKPb5+3LeFA5BktG+/X2g9Xc2d8gv2dIn9zpUhyH+ty+ZvsaoR9Cu1jN7P0xOYmrYwN10Pv0kllUx0SnQ4XXg==","signatures":[{"sig":"MEUCIFjr2sJvTaWHr6Dd87O7yFAoeKi1UCTLp2TUkENJLAMoAiEAteBZ2/JD5i2JoFV6IFJsvKJ059qYUurwWK1elwcJmh4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4479204,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcm0hFCRA9TVsSAnZWagAA7UoP/0sYqe6lMD9dJHtBH5V1\nMs4khxf8iEwHMQvKd55zBd1Af3DYl/jNNnf+vgnnCMDf13VJv5OD1QQuTHaB\neMubgphFXBGmc6peIdTAsuuu+WbHKmit7x2fMWEhHbzR2I7PiJOs4us5ksm+\nBJ/JaikhZLUxHulcApAZz9MnRm20KwUjiFjPaXvGCsKFS0qK+yjjdACPei+y\n7sTiPs0Ew/1fvOh+QDqx4jNShkRMsaa2hLm/jZvkcvaa9poSr1suK1z6G2MY\njhAqMWVI1FAXKxYn/MEcq5pKizXq9yuqc4ux2Y1do0n5fXM1/FNO++tf7R2E\naJw4kSRL5g25I3MjB0xJKrhjtqbhiRWWkqeENxGcSGsMkA+bmSn9KQpSOIaP\ngwm05BnWLS+QaJSycqb0JJnNidilUkAjtCn+8B9lUBskHzYlvjRGXEyfcJKz\nZQISORyofBRFAk1bwRJq29xCF9a/bsnfnnmP4ycneUG+d2GbVyG1nln6piZv\nUIdlo+oReQboRuYm2TdAnO38OKig9A+Z7yKEoXUmavdjMevA9U4h2UYQ9zxH\nNMB31oH2F2kKfENSOtHDmfQDbdcPBGDyOd74FDa0qTfAvB8dHj6xdkBDwzQH\nLGtuf0vxLu/g67EjhtLyXA4juA5vOziSmFNStegTsTuwvK5/6w/bwYECV4P9\nJ+v8\r\n=tvuN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1/ws | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\n\n### Authentication options\n\nOption | Default value | Description\n------ | ------------- | -----------\nauth.apiKey | null | Default API key to use to authenticate.\nauth.privateKey | null | Ethereum private key to use to authenticate.\nauth.provider | null | Ethereum provider used to connect to an account to use to authenticate.\nauth.username | null | Username to use to authenticate. Needs `auth.password` as well.\nauth.password | null | Password to use to authenticate. Needs `auth.username` as well.\nauth.sessionToken | null | Session token to authenticate directly without fetching a token with credentials. If the token expires, a new token cannot be retrieved.\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\nmessage  | A javascript object containing the message itself\nmetadata | Metadata for the message, for example `metadata.timestamp` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`.\ndisconnect() | Disconnects from the server, clearing all subscriptions.\npause() | Disconnects from the server without clearing subscriptions.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client \n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\napiKey   | User key or stream key that authorizes the subscription. If defined, overrides the client's `apiKey`.\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | `{ from: number }` | Fired when a subscription request is acknowledged by the server.\nunsubscribed |  | Fired when an unsubscription is acknowledged by the server.\nresending |  | Fired when the subscription starts resending.\nresent |  | Fired after `resending` when the subscription has finished resending.\nno_resend |  | Fired after `resending` in case there was nothing to resend.\nerror | Error object | Reports errors, for example problems with message content \n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"ca762fabf2797408a595adb57d39bf2bf1855870","scripts":{"dev":"webpack --progress --colors --watch","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.2_1553680452394_0.0992460338557164","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"streamr-client","version":"1.0.2","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@1.0.2","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"d1a8d4d493ec3cafdaef4bff192cdaff206f157b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-1.0.2.tgz","fileCount":58,"integrity":"sha512-uehfuD/b5IVgAQPUmQhaPVhG3TxbpxcUMlv8b9z79KcGe/AjdU1PNj1YutjsHulZ6gKWdc13JfxDq7ktqnyDMg==","signatures":[{"sig":"MEQCICxfF1WQR0aAzR3bTPQ+bmPwtjfkwKqqJmYG2DHNx64GAiBGAc+JFDCtuFHOZwV1jULSC9S+7PTwe0qcdmBK3EWu8g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11000714,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcnRBeCRA9TVsSAnZWagAAJLUP/jF7QxhCUCZUbef4bnGv\nR+3wUbR7MdSqBIh3FcnLLMzRB1OMVtMi2xOu+ER9BoaE27upWhKJBGg53wGu\nV40J1FKl6A2lejleAYrvgT825A6LNDjg90VNdNhMhBMP7BMqwn4M3Dkw6M1h\n7KWogBFPWQntfMKWbufvw/RuOEXQqvbFbVXFyPyB227wooqeJx4awTWr9s9A\nyGhHHmPWD7YfqTAD1gB0kg9jwK9S6kvVQfeJkt+QJB+vkpCIdpl426bImZi8\nN6Vj4dnO4RQCsorG6ZDK7c8Nuz3QnP8jZ6OPy7+C5qVo8/hOCCEyytNWIU3h\nsy+FgG2dcqk5ldeYctuTsrDYAHvE4r675Efo+lDWMN8xJghZIEqppjsWtZUL\n9ttfON/tXoHJIHL3oQLkfPJNJIwiaHfcqJqBG8lh4gPlp90fYFlx0SmI+QP1\nuLnWDqD8RrZPiGejYV6uToBSM+7nQOBrPgZhDrWKAQGcaXNqhjyUSsdZDGdk\nFJkNx914MZLy+FIhMRph5mot2qePT0lqaHyY7vcvIfhVDzupXdl+a7FAwdHW\noT/0PvmWupUc20jhifefAb9tpWWcgUHTsa5voMpZBQn4hWkIwoSfu70etAKD\nobNxvbLl8wGzUX2eS3XMFW1VFp3jUcm2kJrgFBXTXayr/DHGP/9zRhTSPGdW\n7wLT\r\n=ibje\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"0b2c7a65253a40bde8a688808657fe766be212e3","scripts":{"dev":"webpack --progress --colors --watch","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"ws":"^6.1.2","web3":"^1.0.0-beta.50","debug":"^3.1.0","websocket":"^1.0.28","node-fetch":"^2.1.2","querystring":"^0.2.0","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","web3-fake-provider":"^0.1.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^1.2.0","babel-plugin-transform-builtin-extend":"^1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_1.0.2_1553797213477_0.7465111082881035","host":"s3://npm-registry-packages"}},"2.0.0-beta.4":{"name":"streamr-client","version":"2.0.0-beta.4","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.4","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1b7cdc00adcd4cf1e93d2f02b3da398a3db634c6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.4.tgz","fileCount":59,"integrity":"sha512-JEHg5fVMcXH/NrhhQlrkctveM/fTPi3v3n2TwhefzRm0UNHax2wcz8FgqbVphJKUhc9wMniHq/tou7V/zKZrMw==","signatures":[{"sig":"MEUCIQDUV1dNhpI1nycSB2B+fLPUJ3zY7JpJS1GIISTYK2oRjQIgYq/s3Jkx/WpEC/01ZUxmtYdMT4n44xCZfpOKNJETqMI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4481550,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcnfieCRA9TVsSAnZWagAAqfwP/2UjhegrlZyf8WHabyBX\nydaTIEVKOXLcJda9EgS0KHAaN3NXo7vswB2DUYfSANutheelNTLC9PfFT53Q\nMf2yfJBDcJCngPh8x7E9U6gDa4LA2bLbgxf3pm0Z+i8uZfC4wgmu3AKaWaXm\nnd1/TnMKATCyP6985oX3F2H2nh8cjD1GA5mVtPu+nFoZv7/M7OVsGLeKsihi\nospRBetqWAEmFYhQPF1Vnh44GCbUjSsBkxCnvrBS/Ol8Xpu/zBVYGZAlxe9F\nP7lFkkxfQkDWJ16CRwdSn8jijbeX8nHttQ1sGjNrVpEe16CFemVXtiGoj+AF\nwY8zlL9p6kCJKEs6GZXQa648t4UfiVYLojpHAFe7OZObPdRWwNr131aTqEXp\ncIT6WwEew2OCd6QqK3PfUxfPFiaOgmYskS9Otuxaxf0Kq/0yVlLH1fqBTLud\nhFVFVQdgSjZrsGdD1F3Hd9NL5/Bd7wQMSEGhwZwGXk0zr62CJGvzQB+5VqTr\nmC7kvJdH48DlpEGHotJIjGjKCx1r3uSJc1uk9ZsCGrMC2691sLf80iCGBu3b\nmOwW4HwofNv9yK013WPjPPmgXeMb0ZnyHAeXETfQNcOn5tVTdvUQgHma7OR4\ncKKPLZ1qbjZYzWrE8FD2kvtPcVJe3/P773bd/qGM8SwHx5F53bGUZP89jrF5\napdz\r\n=QDIY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\n\n### Authentication options\n\nOption | Default value | Description\n------ | ------------- | -----------\nauth.apiKey | null | Default API key to use to authenticate.\nauth.privateKey | null | Ethereum private key to use to authenticate.\nauth.provider | null | Ethereum provider used to connect to an account to use to authenticate.\nauth.username | null | Username to use to authenticate. Needs `auth.password` as well.\nauth.password | null | Password to use to authenticate. Needs `auth.username` as well.\nauth.sessionToken | null | Session token to authenticate directly without fetching a token with credentials. If the token expires, a new token cannot be retrieved.\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\nmessage  | A javascript object containing the message itself\nmetadata | Metadata for the message, for example `metadata.timestamp` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`.\ndisconnect() | Disconnects from the server, clearing all subscriptions.\npause() | Disconnects from the server without clearing subscriptions.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client \n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\napiKey   | User key or stream key that authorizes the subscription. If defined, overrides the client's `apiKey`.\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | `{ from: number }` | Fired when a subscription request is acknowledged by the server.\nunsubscribed |  | Fired when an unsubscription is acknowledged by the server.\nresending |  | Fired when the subscription starts resending.\nresent |  | Fired after `resending` when the subscription has finished resending.\nno_resend |  | Fired after `resending` in case there was nothing to resend.\nerror | Error object | Reports errors, for example problems with message content \n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"069dba201625316c6e419111445b4d34c63440f4","scripts":{"dev":"webpack --progress --colors --watch","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.4_1553856670109_0.12406886251020355","host":"s3://npm-registry-packages"}},"2.0.0-beta.5":{"name":"streamr-client","version":"2.0.0-beta.5","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.5","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"4fcbdd30ec2f9b6bfd7e51ba172193806b9e4be8","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.5.tgz","fileCount":62,"integrity":"sha512-m9MwSHqNigg5hCuc9ag+Hgr8cyEAYk8eJJtk/froCcJSKjbSzFTSL7U6DpsfDgFTMHa04+DGSbJXCkDHelCnXQ==","signatures":[{"sig":"MEYCIQDpUt85Otp++yBlZK3ei4HCqmIGOdllUwaCzrWuubu9ngIhALmzojdB7eIpMBJrTJK9GQnUjZquFcDMIDliC7hN6kXG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4882367,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcrww2CRA9TVsSAnZWagAAfk0P/3lMelOCXMCaqoiXz1Ge\nkCi5AwPGMH1dx8lvpTWxzT9Y6fcmwonEruAZhB6JiW4aXxlI2t2zx7zP10mN\n7W0CQfW7vc0X/OMWxVOEi06IjOGUpbDy3p7esYsXcWM4IJGnNTE9ynzaHwHX\n8zFW68+dIT67YN6Badz2292Ec1spy9RpwE+KWR0aTSVfOTeX/Xcphlt6KDbS\nh/ygrBZ4iNFMW4AV2Yvk1PHLC/GrrXswJCo8r6vefXA7EkRlLHahVSOFK+9d\nHR2IwacU/zDgwOY4rP3JL1Q5k21M2MS16z9HFUpBKK19dTGqpPVc//dB/A6e\ni+j+JYqn/7liOIyc4mQwi4mPN0Z1syEv+hu86HB3FJd88vXwb9DmyZhl02W0\n1nqboba2b4PJAxtjLUzFb7xFItyRLWnOyHe3EkzodfA+uAVb63V/f4EnJtla\npmzN2cT+wafLWFIlCLMy9UbLD/y+2VFO6XAvHBfS2H/4BqwYkOKDoAAO3Y/U\nPHQCr+K45Od3Y2osynfJ0hJo6P1k/u2kmt3Ri50YlYnVk7swgT0YxBPfKhW3\n5Dm1WoobXy4jo3opZTbQYGikcp313NmF3U42O+WkDQqHKZrLaupGh5Guh0k8\nHoAYVyr7f/aDCDRhh3b0G8BSn38d5yf/jucSSUuRk6I1ubZkPrfzZx72t/LF\n/xFs\r\n=Kzkv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://www.streamr.com)):\n```\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge (also automatically creates an associated user account):\n```\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"39db82ddcdf7e0da8917b85768a359c338704965","scripts":{"dev":"webpack --progress --colors --watch","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^3.10.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^1.9.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","uglifyjs-webpack-plugin":"^1.2.4","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.5_1554975797448_0.6783213068437481","host":"s3://npm-registry-packages"}},"2.0.0-beta.6":{"name":"streamr-client","version":"2.0.0-beta.6","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.6","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"88fd3d3a84d00384d28958ad2727b50ab67a7c10","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.6.tgz","fileCount":63,"integrity":"sha512-r1pHfXEHlesmNjwbvR5L5XgmXfpKVhdkKkifcaLD9Og2wJdj5b5hfFYPaBxEDxWZcVpI2NtcydS8H1lzrsCZxw==","signatures":[{"sig":"MEUCIAJBhT40eGhyJleHGeiZss89sxRzGg+AqOkbe8ctpIyzAiEA5z3EjpkyhauMQH48G3OtQT7L79i+w88GOGalS9r9878=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4130435,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc1S9DCRA9TVsSAnZWagAAewMQAJJN5EN9XJ5fJc/ZTElg\nWHjbifIDMqBpT/+5sE1UoUlgo3mmp1Q5/yE/5VZwAxshTibGFDK5gsDgRDx+\nXnk2A+I2uPxMEb7uB2izylT7bGQKcEm+LAdowXYyk6zLNp3qvLhAj4Agmxzo\nuq39NWjieEVzmZvkIkXmJiaNsYk20MOC7srSa6ipBVDe4k36lJnaIDVnQxEx\nHmBPImoZ7DEtSrAtwZtmnEvTCTenEq68DpvnM6seg5VmsqDSQQy+5ALdBj/H\np3E70LTOMQpQkp9uJsgCxRmb+HVBwBzz44slVehjLob6Fo4FNnEN//FgvRV0\nKeH3nCZx6eBYNuZxwKFNQ8mkuGoiH6w4DRbWO0GYsdO1pp79KduF3wZbLEVQ\npNn6TBhDq4ezfDKfGn9OmUI7KFp+3mnVfmNvn+vYoTumpYDyux1tU35FfFJg\nDPqaCSlkWmfG+9T055U/ZwYp/OVazbqqbaLDHnq7hQe99Zb0HkWpFp65hknf\nMCOTnN5HUy0OpzitMIo3fh9+iau1hnq1BjAW0VtyvGzofeH7u0sF2jbsc2nM\nMQnqGoXt6qcnfKVBAk5yrw4AKPy6Zj/XdhI2QzR8UGMKx4g3WQK8tEv+vRyF\n3KsNjgusfB9Z5FM/kpmXHtbwE8vSjWOKmWFgsepJnma3BRepIpvQCGCMP1ZN\nUddn\r\n=dBum\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://www.streamr.com)):\n```\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge (also automatically creates an associated user account):\n```\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"c5df796f3904972645a66278b3e5d6b3a15dca32","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.6_1557475138617_0.8743325163443165","host":"s3://npm-registry-packages"}},"2.0.0-beta.7":{"name":"streamr-client","version":"2.0.0-beta.7","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.7","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"99ea60b75ddd200e9028a3e98657ab93720607df","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.7.tgz","fileCount":65,"integrity":"sha512-USuvJ2fOlsABmLSYm/FOQjZdFIu1foyUdm9hpUebY2VEoJjJMlbACPNKd6peCB7fHIPR9yOI1hv1Tp9Da+aygA==","signatures":[{"sig":"MEUCIQD+2+c6R/lWuHR43DX4XviDMMf6+zSXqSco/89NFbYm/AIgPeI4hbkyCwKkc36nFxMN4C7bA4DEqaTesXyVcUnaikM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6264017,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc1VkJCRA9TVsSAnZWagAAajQP/2F9foEZ1Em2gLhMp5lA\n8y0eOrtk3LktpMAk4G7hKuPZWDXm57W8x9Tex7e4N6E65h9ATHgFGoeUp+fn\nF1RuUNwqoCwsfdz+MwO/A0cmOSeUtD2hTohdDuImcvRigRXCwPaql+8tCjws\npumdYF2G4PcQzFGaw5JmeKss3LsQnxvbdRvxSdVQFIu6u0uTVMRUvIlrkP6Y\nZohhlOLVHIFvl7To+20o0cGDrElDSNwbwpe8iPho3G45FgA75b0sSZ7ai74P\njVzP2lqhxqeJ29SjZOhRIgcBFIhRa5ZKLJtgIh0tNmv5cQTMwFRYEVLmwhu/\nE86E/n50FX7WbB7COgs9Q6hq8URBqdKIMbHhiMec0x90nGE9hGvgbltQyK6O\nTYMnh0fsDHKrxaHtGx8DqQDaT0HKclgdFrV1otK7nIEMGocrHAOnTXRg0z00\nxQOiO6IA2hA/foAC+l8ttDTV3x+2f8OI/rltHF4s0F2rxbtPg1api2kHT0Vb\nUo3U4wcEjpZ4I8Mc12X+r/tYgzUWiBVpH/B7X1Odhemr35ii8HjBiSTfYLBy\n7RAwwoBzyTEM68VTZQlVQl/Ra5b0dd6lQYA8WQeNtQ8E5U4XQzvpEFokQpJq\ncFoKloytPlv27bJFZbrzkWCW7xat+mggLop572l4+HEbk+swWP8/xVLVvvNh\nX/T+\r\n=n91G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"508132071fb5423da7eafa1c5ace7f85f84e5b54","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mariusz_io","email":"mariusz@mariusz.io"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.8.0","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"9.9.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.7_1557485833072_0.037637559800974385","host":"s3://npm-registry-packages"}},"2.0.0-beta.9":{"name":"streamr-client","version":"2.0.0-beta.9","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0-beta.9","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3d52726ba619646c8433c803b50ba5f726ee9c50","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0-beta.9.tgz","fileCount":66,"integrity":"sha512-C74bhl/z/i55Fv6kSQj3faxDlS7vTlawj877uRGFZIc9OWifBpLuEOYEGC/PXX8l4xSBdiy/DfrVffywNdjRsw==","signatures":[{"sig":"MEQCIE0FKx3lpuX9m03Vch4r1u/JdDJ2fxAtYbvoDogbLaseAiBVBv7GSMxhvlNFsNHxFR0CVGRGulg6a2Wm/GFzL9HjqA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4330570,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc2XtCCRA9TVsSAnZWagAAS8EP/jl0Bnhvjeuk5D+riAif\nsQ3Y8XUjBgzaH50alcq7txIASwa2TG2KUUvgAtui1GDMvP5D7z/6RuCFFz73\nCzVLsyGLX5Qsxso/Aecm6wxccBVYKQ/o+9zxbM72DrVzMtm8DFnGCk/Kx8sF\nlkQ128gjut96L2mrKaZQIABybTNDOh7z608CxB3+oUQuCJG/QOa/izZWs8sH\nO1B0ODAddqFXKUd3Ky8I78wjIkvSDfHLM9GOelElOsTR4dom/sCjzLfgJVAO\nllCLzoiC+PtKPCJdqNJy6HGHLdS5qkuCuGBHIcoK+tba3dYbL/fqo9yQMP6t\nPRMPt+HtAXWrEG5UElRs6I7zoWxoVbHAk/T7iuxsQV9NiSyacTXZgo4y7S5j\nRM1hP/R7QOHZGEQymDqFeX1r1aymKQD2qw482yV4R5yKeqErfJP0Fle9JXiH\n9Ty+0VlN0PQ888vQU+01hsu4efdG6OyuIqH8Dedej3E/3LJYWObHuNUCGsA2\nvJx3SUQGaeUH5OPL7eNLduC1qpx3AniACg64/CjCdp/rDd9BQjVrmyfndJmb\nZOADxkKb/9cxB/RHHMLSebHDOKE6KsohE51lakaX0oa2nVuf7a6WN1/pzAYy\n+908+vbvJdQtY8uxnHzrOhCLRQVqenqpiaGnWbLlgdOH6TBtnWDrxhHXQBj9\nZUdX\r\n=gfBT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://www.streamr.com)):\n```\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge (also automatically creates an associated user account):\n```\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"0f1e21281d3bd551332e3246cdf64ade62c012dc","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.9.0","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.15.3","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0-beta.9_1557756737480_0.11970504096318324","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"streamr-client","version":"2.0.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e611972206fe86c1f48bed90b073ae47b0da633a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.0.tgz","fileCount":64,"integrity":"sha512-34bUYB73tnjapXU6XGYjgXEPbiMjlv3QifGYLsipiNwaAY8rAPqIphp9en29PdzMynQe06EupuMriEcf33QqNA==","signatures":[{"sig":"MEUCIFeTMSjP3u+93Ne1Jkb6/iC6zuBDy2RCOJWkX19fwy2WAiEAtDfn75MFzU4ArjwNhb6sOZPhLzNxkd1cBNtcEdhO0IE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4192006,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc3pbCCRA9TVsSAnZWagAAxtYP/Rh0ccwYUhoFlZQiU3wz\nqKAhiU9OzDHQmctc83UvltG9h6KPGwU+p7SP6bL/lp0gr/yXlR1/LRehcxhN\n7JbRB5dxIrkV2UqarK6fqnGud07H+IvqUY+kkYC6lg+SLJo6YZwxxOC83QgN\n86wuXOAmTiVYwwQEFFLfTJYYkGQXyOEr4cBzyzEP+PrtoN9Aexu1ph1T1lf+\nUJ2c4l1hPSMd0zMfCAJZoX7e/5mWaeI63JbC4ZbvuoWV49rLTtOFkvR7Z416\nDWPUoCGXooTPPbcM1/RHsAOfVIQYdonikwr8SK/CM7ypI5pwuS/WGlPXTgt2\nM+RphjGAoKleTAiWZJiLLGK5Y5btJAjpjgaDGanJH0TColsN6YAHLr86V3ik\neOXMewbJqnnmb/XQ0JgBjj8oyLOZLs5Op5eOzBG9E9M3/mLgVSxWWJw7R+jx\npaaTmb981IQKyGiu1a0mD4px8wZVcZ886Uu1GrxcZqeXYqu/82BGx0oEJSB6\n+/HSDLskymwYuZy2FEu6qzB+k4ZD8L/N841QYElTacapoBYyPf00JpN7wfDB\nUtRY3liyPh3a/EMHyN96izsfcuW+OM/qj3q/+CLKND/DRzCiTr8CpAaBOH2D\nAaXyeBr9HV4XjPzjmscKXc/C37a0pfLX3gBVYIP1rVJbUyJm7FtnQjwAqrim\ni7QX\r\n=qUDw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"d94aba249610a572f311f9395279377311aa53e3","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.0_1558091457378_0.5884481768891336","host":"s3://npm-registry-packages"}},"2.0.1":{"name":"streamr-client","version":"2.0.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"4647d6cb6ef00371d9842db78cdff35c358dee1c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.1.tgz","fileCount":64,"integrity":"sha512-Zgu/wetmSqJ5gcByo4hN66XUFABRH6m4cYCJMlHVm6Ph9KVfrC9+9AMskx2WIgovc5pwT+3v1i6DDRt570+Hhw==","signatures":[{"sig":"MEUCIQDsan3cf8sCalEe+JXoEAWgZPs3/2NISuhSsOv+q8ClogIgZXezWDhp2jVrjDWoYcxp4YjRyOxUzR9atiZvFESrMWo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4150930,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc56lOCRA9TVsSAnZWagAA2T4QAIsUY5qENzD3xhyFBRN1\nlzuhTySqcLWWCTvtIMo32mTGm/BMCiS/PDLFYnpZeDyWFKHF47MqVGhLTRrl\n+E3PLtpCFExUEjjXAuzc9npu4g655R7V2yt6zZZoW8kQnDmGnTybYdfnaZ/P\n3a2Aknv0+0nxR8JwhRL+VpLbun+/96wZcT7hsv1andG6uBzOrorofI6QedQb\n41JdDxFABckLD8xv6eYi/yDTIuVl3ZFP+FAzsnfwEERLIEivqL56t6PymMAM\nV0mPBtWUgN3uxu6xoLyH8FcV2GFVBIn04aiOHsj6MfurFbsFTLHGo+6gNa7z\n0/Zu2qEhHXXrbPuIR9BvTVTJLiwkcOumGSSyeBfJGlMC3oC8AZq7fNHN4har\nBi9jzRyA0y/oH8A5qNKHkdw28MMX7oufgMHB44krJf19cEhKADf+IOwxomZ4\nD/9y7qvSaD+umpLYJiXaPQDz0nG9IjsjImbEVr9auctRMcr1/NbkEv4pWc8M\nOwiPWTVVrWf8NqV745eCI2PrFFR0LcAZxk34Cp9OB3X+x3AgI7haa3nAC4MV\nG4jrfacUpqQmNjgjUnCj/AQo/fUYrSVqi8j/mqEruPL071JUqwS7wM/NH8ZD\nw8VELdZsGIa21VOx8ZtqhoDlIIyeWVAmKnPaKvX4GCk6mamR9iA2sDE7yLIp\neC5o\r\n=xqUt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"13a2d96501eec48d696d91369759a4014f5f11c2","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.1_1558686029649_0.8243542321072828","host":"s3://npm-registry-packages"}},"2.0.2":{"name":"streamr-client","version":"2.0.2","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.2","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"af3659fd49a3d294497a8704a1854cab0f391a29","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.2.tgz","fileCount":66,"integrity":"sha512-jOOQ+ZyBpLHQPsvWr7f8qlzj9qjOEqmOwWlrC9mespVCM6Ah8fdTEgtfgQun0ZawxOqgm8wCaHyx1Er1LuBdmA==","signatures":[{"sig":"MEUCIB9O0w0wJFxR8ZT8eI8MOuLwl4n1ReefRoFAjHa6NSbXAiEA7MHgL9T57nfL3bp40K2eJI9E+/evAd8iu8Z2tmM6ozA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8983936,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc6CNzCRA9TVsSAnZWagAAp5QP/2gAZy3gxSgjQPMWOoMG\nGrCnYMO6q6O+68sGwhm1PHW2mWvfN/Fidu7lPwFiSKTaJgj1CDMkDB2CvlYU\n+HVA+A3Y7N/74swzsHmvZHfnZmpKtYQDAWo2tOcVx1iel4Cl+hIEkPAuT1d0\nu+jsHkTkfxdLsb42t7WhXwnRlAVI0tZ32hVwJzKDqW8B1RA8pJj6SK2H4+ut\n/7yzojjNSdwlElbqxruIeDI5TD/UPTp28vG+aW3Sz0pK39AWUS36PWpKrjHd\nEgQxHPRxCqfOUyLWvnAkhgA6BFgH7TOXp1BrSj1ikfG0CZ7fxMbXV8LQbtFw\ntWh48OonzBXwiMYTi+6I3gno0FQVqON4evq2WLszYImkjfG6gnKCScjQQIMl\nviy+aaaBx7gm++ula1en8Rpk0nVfHLDKA6i3ExaztPfZ9kFERmlL/X2xd7s2\nyNvsF9XnoI4w39TuGa2U5v23i6NlR+B3+vSecMpQhCtEU3t1H6T7PNtZvCvt\nAowYv34B5gPf/a01CszytccFphSTlbS0tknjx01trwnDbp9k4tVLrfxlXZ9N\n+/3XuDA43wf6ctewQl5Fgo8bPMNRmRCvvkYFq693iLtDrOXFxG9+CQNdsk6q\nHXoUQE+JZtdnngSuDA8kFa8rnBUy8j1lDqYqG1D2SOVGpJQ83y9sjvy0DZZV\nSoSr\r\n=Hzr6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"e6acb925a76c89465b4d100b604ac9cf283bcebc","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-cache":"^4.2.0","node-fetch":"^2.1.2","querystring":"^0.2.0","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.2_1558717299097_0.2368216120033131","host":"s3://npm-registry-packages"}},"2.0.3":{"name":"streamr-client","version":"2.0.3","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.0.3","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"d00358b15856104a434d364e817321fdbefe0074","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.0.3.tgz","fileCount":64,"integrity":"sha512-KPcxGg2/wF2V+3/yX1NLcwZ8HFVelvDHICOl8m8/WRP1S3r8Opd0jnI8FgukAKJ97plDorBYFCYTNQMJYTLLaQ==","signatures":[{"sig":"MEYCIQCcf/cu7AlLGEJnvZkPkGNT6QzIKB1Fto9m2qf3uoOz0wIhAJtnTtMw3pSPVakTumNTC8Isuni8o5fUvjK0TV2sk48s","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4034725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdClebCRA9TVsSAnZWagAAUe8P/2oqydJpTgPNu03iBJwO\niohLVqgNwBs/amuDPbQ0mJ/e2hdTaSrf9eCQHAtsycFnBRRZWy7gcKgzd6/R\n4kB1wB/8uVZ8uxtEGA5JCV/PsJQjSAdx+EMQL2ZOQfNU2b865Gdqw3lfSxVw\n+IQRaPIk9sNMNWHnN4ql2/ArM9nVNeTT2f/l7R7Gly3w7O2RhwE7km+maiVB\nQ6fJykboQtg1RXBkZW+gRKMGund589SntmT++KA9Glc6gGwO1gQ8hfm0jS3c\nXhBAWRkcXwV/MjQ0OIKtxNIva/i+aHl2I+SSxstW56m4JyVtXA8YjOgvJZbN\nemzF9NxYX68HD/aH/V3caFLk4CYAyp9qt6I3YjwPJkdHLbifrEho8qpUqyYZ\n1ckAKoCHDnhKohMlBdUQi1QABd38LRtABZopDFNETqiKJSTtRh98sdfTgm6p\nIBw/igDgW5mjYCr3m72T+UWa0jjNVwVlQS8YLfw4hWAlQoT9Es9nO4cIaStW\nlv+uCvjhCBt2mrSr4VV0plY5+uITYI9M6eFUDz5CM+j8vdpLqYnSJSWzCiQ9\nvPs282iHCKHpzGq7+xFEIMv4ca1ALzX/FLmgA7mk5wbYc39vl3H9rZffIzc7\npJYLv6IHJ7krXXeid98s2YEwuSMzuyVt3LgYsWUHXZH40sluesPOFLRSQr2q\ncCSX\r\n=krnU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"ec3b6ea2cfa0def776e44b8096ffafdb4025f1e3","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.0.3_1560958874491_0.4660982877652935","host":"s3://npm-registry-packages"}},"2.1.0-beta.0":{"name":"streamr-client","version":"2.1.0-beta.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.1.0-beta.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2b88c8af22a2521170108b67fef3378a98bf774b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.1.0-beta.0.tgz","fileCount":66,"integrity":"sha512-UV9D/g2Odou1wmOHcFLuEw2MqkxoirnMAsgreA+YLPek8YznBz4XSIeOlq1mndvc3vsUC3siC5Bix6AC1Xm9/A==","signatures":[{"sig":"MEYCIQDOGbkcQGyppwiMrnIK0Y1ef310PweMvt6SKNYFl0zUsgIhAPQP8qkJQZnl+HnKdHdWYwgxejbWJB273jGpFexIy16X","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4075906,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdFb/CCRA9TVsSAnZWagAA718P/27mSvLEuGcrnbIfAWU9\nsCVGRL58PLlBgziv8lSSz6j4h0TeA6QYDJVUxPUZ1SFU4CghriTHTNBdWi3k\nGB1oVK41YbrKfMeczty0kiHk99XEZvbULa5DerLHLW+97mrTyJRQKQV+myLa\nRXX1vXmrMllPl1EyBFLRRD6DoYNGNTsS+lLMLAOxgCZgD6bCR1NDXtROUuyJ\nCS3VB/kkgQyouOtj9i21EVFP58m5yiruy0QnZfl5hpKxRyHAsas/NLd8p7By\nz5a+x5etiG1FDcnK2abhoI0X22ORC6YnDvMym/zFo2A1/3tySG/BHRUJHxbj\nAxoifyDtAuiKnrtwIyofG2E5VJucE5mLTXnHARDfvvv4QnZGaoSiC47ALtfB\nOsP7rsRMsly5IYM6toqpgc/AUdmMlInyTPrA7kGlqfQNJ62Oy0eoHHXNWx1M\nZyCUQZtiK5LDmfCMVByFVfYkywavL+PyYoM/dwe99VoCYVTN4Tk1+/t+AZJG\n2Z7AJmx4mH0/vK1klAE3eVSi1e8tLDC6ObKzxiNgyzanc2Rh9P657QNUhm5a\nlcuV6CGlqk9iWcclI5e0/7yaqqraeJl5ezAVrVZn8Ov1U1aZALwYQ9Utcg4D\nyN+ANbUhWsbuPFlEoJzERJSc8+tMiZE9nED3dQ0EkYwbIhWsOpmM49+P90uj\nYD8A\r\n=jFCy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Producing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://www.streamr.com)):\n```\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge (also automatically creates an associated user account):\n```\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"eba4025804191824e0e00e0d0c525070cf5184c5","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.1.0-beta.0_1561706434085_0.6003506328837278","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"streamr-client","version":"2.1.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.1.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c4db394727d6528dd90198f88e21ac22370cd508","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.1.0.tgz","fileCount":66,"integrity":"sha512-TeAnMpOAXOqj3uvRu7McFykF7YWd7wzhBkw8D0ETgHOekp0D1+TjqZCJsn3qGdhgh9XAW2bmOkZMS+ucHNZKGg==","signatures":[{"sig":"MEUCIGB1RmtveijnixhgGMdEUElxGk268BcRDJBi/mh2k4kFAiEAvr8hrAA5kNk+8ct7uFeSLRwJGQUbSJQKGGSv1hGwiMs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3799107,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdHG3eCRA9TVsSAnZWagAABdcP/AoNkjZ7zSdgnJ9f3T4y\n9cHxZ5G9uxsJ7C1eEPOB5870pbipD2jlMYZLP79GK/k+t/CjzZ9y6DnCxRVZ\nEkn4nVm7JgeZ1PuPZ5MdC6Eq++rlU1QFg0CbxnDQZRoy8Re6TsszhCgjVTTJ\n8DBJJhQKnUJwrbPP2hnBPWNPxaGVS8yafAUfQjRqJBeFRi+QMa0c0PJXbG6G\n4SXUQ9buItlVh0MOi1UjSfHeQP1AHLGzroKNgBxu3I/pg1k7qOBEP4R3MaDY\nkfpdIDvl0bwlKKNBnQjxDfanh60WnsSQKScK7zqm3/uA4JVtR6BM0mxkpyeg\nePaU38k5OL84yNaFwOn3kMxBYPtnujx0dFr2i1tttg8yWDoj/XKOJvckek8z\naO92szKJ1jBkAEVuyIGIoUIYuhE2SCymgJNBhX7xa7C+TDDdEj9A19fL/UXs\nhX7eT9Cy/3sR0MNxyFRjPqjN/O41F9XbI3P6FfStO9Op6EsonnIqHE26hUQO\ny4AxKxCz0zsPs4a0cRJQTbNVxQHMXvY62GgevvWYwXljHX3brWBMGYB1XcSy\nQlRwD0rkx+doQoH2eQ+jBjp/PR3FKx9pMZKxsdENlAkDXgccV1fahon8/NQm\nsL61CBaFWDxmGyney3dM0C2Gd/Zv5rGV84E0Oh2ggC73/U5IU1evRfit3fEU\nGFAD\r\n=MruT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"18918a6e6cbe902d3f11a54111f9f842cdff0310","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.1.0_1562144221794_0.08248315375889836","host":"s3://npm-registry-packages"}},"2.1.1":{"name":"streamr-client","version":"2.1.1","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.1.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"97619a542ee748e242f798dfecf6eb2c6db78017","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.1.1.tgz","fileCount":66,"integrity":"sha512-R7dNb7/QiqbwRV3Y0c2zrmRX+/IuwsrlS/xclaeHOiZ83U2FVYDN0rHrbNSHX6O2WWLoAZzsMduvQDR7Hy1qdA==","signatures":[{"sig":"MEUCIHSdyN8kD0lNEUQU1cpFJBBPMPJFL5mVFEvxynfaTG5bAiEA9K+hYZaa4ZolFirn4vNi26hQmfeHEKqE/w8ME+9BRHE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3799107,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdHupdCRA9TVsSAnZWagAADyUP/iN4VbXwPlaM0AQp2eIh\npI/l89Tmb4gfL+BI2wA7hvZZPEgarsPrmvgbYZu1aCXU9hpJ9M8NY4snWjPD\n/qXNwbwFG61tOu52D/cEHETclOnznXicgPnv7udKEG0ohbdF2g4fp/0qwhq2\n3dbXTiVouRaCBGrKeCqlIvS/jdz/X7AFdaycHBUx1SY8TFuuRtTinmPB+m7q\n1+ELFx8qltAC39tlYUOiBxk6Xw5+WR+HQ2Q2uBEJVXgU3112sDCETH2FziZI\nKrHOnwicqqH+k5MkWSz3xxuexqaxhZ+8wHWUmct808xPjZv98QwU5Z+tzfDa\n1IIrXUTtFtx6h3LTwk3ndf2kw/AwANRm6SOM/oXrpDarVu+EYa9feNB/tJcD\nmp2/z5ikRc6d4Kj8YZ36yMV+DLCrJSS1Sv1rcQXmwRyVGAvTpTDVN0oh8nE4\nz1BBDg03Ktq/Hv0/yCnbQlW9Zm7O4wbQ/fhXgNBG3S+0+EUV/frk1gSRIihb\nygremHUy2prD53TM/E0aei/vduPO5P3w26cCZWQ86ImSatthqB++v1env2F0\nLeJxD1a42Llmmlmvfz5n1H5IPtBj42oOBs0iKkJlav0s1/c6BXgi8NO90s3R\n5Ni/JstbDMF0HWC2oZZce+LyZoRIAz9r4JyTfIuK8Rqxe5jXcfaV8PJSTJ7G\nk889\r\n=6FkV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"3b7e1383997ac79ce7fd22fd2ef1a774a1d6a579","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"npm run eslint && jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint src/** test/**","prepack":"npm run build","test-unit":"jest --detectOpenHandles --forceExit test/unit","test-integration":"jest --detectOpenHandles --forceExit --runInBand test/integration"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.6.0","ws":"^6.1.2","once":"^1.4.0","debug":"^3.1.0","ethers":"^4.0.27","websocket":"^1.0.28","node-fetch":"^2.1.2","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^3.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.2","jest":"^23.6.0","sinon":"^6.3.5","eslint":"^4.19.1","lodash":"^4.17.10","express":"^4.16.4","webpack":"^4.30.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","webpack-cli":"^3.3.2","babel-eslint":"^8.2.2","babel-loader":"^7.1.2","eslint-loader":"^2.1.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-2017":"0.0.0","eslint-plugin-react":"^7.7.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.10.0","eslint-config-streamr":"^1.1.7","terser-webpack-plugin":"^1.2.3","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-jsx-a11y":"^6.0.3","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.1.1_1562307164913_0.3108794533428063","host":"s3://npm-registry-packages"}},"2.2.0-beta.0":{"name":"streamr-client","version":"2.2.0-beta.0","author":{"name":"Streamr"},"license":"AGPL-3.0-or-later","_id":"streamr-client@2.2.0-beta.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0203822c2b7f55e8e12fedbfd9e3209270fe1945","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.0-beta.0.tgz","fileCount":76,"integrity":"sha512-33VPYw7I0gp/57/euUsh7oaW9+fQtJgJkvzEuyn8q42I2KPMsaVRKCUcL2AoesN2sZROYX7PzwxO9y/xlFLe2g==","signatures":[{"sig":"MEQCIDpJOJwlFlES0ELtSteJPrv1WJt8heCj055ev78rMBkoAiB5Efh6QdlBTBsNYEuMW/Em87ae7xwW4GofosaVJjn6aA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5463220,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdVq1lCRA9TVsSAnZWagAAMu4P/1niVsHxkH+jKqZRCBv/\nBp5m8f69im2QrsPmem/On2NmBKOxX6Elf9c6nLkUhdWvJ9StCvriXGzi4Eu4\nlqTfz5Kwo2kW+lUiuvAkiE0ZYtiKHfY9CPXmCR6ApgSAmHoeAIyYV2u7qYf+\nxvIwr3ldzG5ZIzBUTT0Unnd/le6Q4emtIqXyd0PvhkRhdZvDViHOXXzRwUIk\ns2wW5kcKSwpSto61+feB/HhwHWAst0MBxpY1ladWzYv00CqEBn/qZBCIz842\nw29+aeFqprqa9Lz1CijgXmYug9adudqAomaZnFMw+Wz4o73ckcXLjaBVipOy\nap5dAsAm9ebKq27erR5NVVPZfzIG6al2BlfB4zpeK3BgTArnnm4TMrlFHbOm\n96fzQu5+JGzERYeAlrBSLNBMGDwklfCf2JcsvHAzr9hmrQE3jf5aHnJdVvj/\nMQ6L3vYRSQyiueiHY8mBWcvU+wDJLxbd7tXQimMkppw8aqP2THsAk4MhAY3J\nm1WrAvVZsZhpGUH6b2QyGx0ht0jat8AWzkMKyYt2cEmft5SQJhc6LnedWnhV\nwfQf2HsE6VI32QeovmsTOaMB/KzQXrD3j8ISY7JDUMfs4xbXd/bkACB+mbdj\nGvVbfdYXr3DfYTBBk8m0WNYYXo8h6MYj3sIhpsRAnN9GySFAGoVKMZ+Rokiq\nEWnT\r\n=h+TE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](http://www.streamr.com) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simpy by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// Or alternatively, via the Stream object (from e.g. getOrCreateStream)\nstream.publish(msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (default is null which will publish to stream partition 0)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://www.streamr.com/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://www.streamr.com)):\n```\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge (also automatically creates an associated user account):\n```\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message) | Publishes a new message (data point) to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message) | Publishes a new message (data point) to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to the default partition (0).\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"047f0c3897f708178b1c4a889713d2cce63e6ef4","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.9.0","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.15.3","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.27","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.0-beta.0_1565961572328_0.1899731134657705","host":"s3://npm-registry-packages"}},"2.2.0":{"name":"streamr-client","version":"2.2.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.0","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e6f32759c89fb362fabdd90236ed82354c9e9ef5","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.0.tgz","fileCount":73,"integrity":"sha512-sRKGhsEULTmYF8cFzak+Pm80Gz3o+UE1iAMjYv0DJj/qHsh8ePIu5opvBC3VovPPtxYh7miamyki/iOrauiZ6A==","signatures":[{"sig":"MEQCIEHGFrlkRNlR38oEk5Na5JZNlZ26uxt+TEiLOPN2yCPoAiB/hIbJws+cHSiAkxRn2aIRIMXuVShhv7FqiTuA9AaVVg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3865358,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZmNXCRA9TVsSAnZWagAAmGEP/A7DH1OuMefV9AjyaoGQ\nD0PmyBn72hS+cKrkd0TumFBrpLE2fvODoBFDg2X44mNvw1jP9HceRXlPexcn\nQSdns9oV2m1e7WgG6Y9aYD3rYyskPF8rCrpOcIkucqdkpZre0VSUHfmtP1+y\nhyFeP9jEiTdwGzEjERvPf4fRKUG7dfVMEcOVLuMvx/46H6YoO58QC2uk7Mbw\noIQucBhE9H2lxXYY4yo4VapIMXEBXPCaale++930cKqMzsFJQxDwDiJd20vm\n9z5EJakOQjTPENurbEnl3cmoiP9zwF/5xQGMC3ikHFsYXpJ/5TDg+smB0uQ3\nB91z4qXygFuVVnYYeJR9aiUcyL2r3+4MC3JfrsqYIRg++K2J1oOHNJFnVzYs\noQislxphE6P0/s1uYhGeR+YxCs9dmxLn9HrRaeyp3b9XKGKF2kByEI8yMHj7\no7D2p811IUwaY5lqYj75VwOyj0wORsaXeFXGa7cXVp6Fpb2R5B6xtGCmNTJL\nEXcRRtWbPAedBX5fJiJViMcDyIaIOib81nXrVu7len66n1gI0dGixqOAcmkL\niJn/03PVndP9jtuo0Pf8fE40hC5/UtOXCL/rrS71/jeYaZ6LKHm+Ki7KBoBN\nuSMMxWzjeWYvUqtZCnLp3ATYvc+zxIn1oCP0Fgp2yr/RBYPYDBvC4tmRELTw\nodpi\r\n=mQjT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"93d96682afd2280d1c40e30d20be9e504ffc86ee","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.27","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","babel-runtime":"^6.26.0","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.0_1566991190321_0.8383142785398185","host":"s3://npm-registry-packages"}},"2.2.1":{"name":"streamr-client","version":"2.2.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.1","maintainers":[{"name":"aapzu","email":"aapzu@iki.fi"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c5826f03f7f58be5705242ecc4f7e87e49fc73bf","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.1.tgz","fileCount":75,"integrity":"sha512-gKpM40ENigFMnEQDlaNeSxUntO2wp5gNYIOH4TZtUa2ykXMqxJ6H7BbqmS2nL/tMCJZFGR6oQBw/QWAu6A8Euw==","signatures":[{"sig":"MEQCIAUBtgqXnHi2w5RC95D4hfW6LUEOrLE5MGXIiljaTGmmAiAYgsar3IOd3o3g+8WnN1rrp4o+MA9nHCCriA6LHhDp9A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8697593,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdb96ZCRA9TVsSAnZWagAAUAwQAIZDEESqOntV6R+/b5bS\nRik4fH2SaQJ9MhIcbyp8omcuH4ZJPXCwDRCU5UChQ34ekQkZjRauN1c+cV7+\n0gaSF3fULS/SJKpf+gegnzUIIJl9ppV8OCp6kdM5OFIJuUHpb+JLhf2HtG1L\nMCwZKz++AzwHpN2OSqaOhQvlQ/xJmx/GeTnY4TtX1SYqXZ69zNythtFciuc9\nAtXmAzYYlrBhZZlisKOkPSYmPogUan9TQvG1voGG07v0UNrgKURwa045n2NP\njoWOwXxg4xusXNd9nEuADyM+G6jhi9Ol6euLKYQxrRTXC/Z4n9CsB0QVvqL2\nats6F0hhBs4gvrqp2KZBO87Nuv7nKtUUrtbdIA9/bJWKE9bt8jzlK07v7hBe\nnNpY6gVgvVnobM3dEMQ0pJK9UhZe29C2cZxNIhWAUeFFaWxBrTVfQxisnl4O\nbomLHZO8cE+CLI8Cfb9mLGGg6PSrz6sE0ICeHfF5aZ3txruCWZ63zv3DzJSC\nUwAkkx28ej51sifSHQWktQ/CPja5cKJAgyYBiLVpJEhKwuuEtf4mXBGkVCWB\n1znksGPaw/DauZ/HUHDmkPlqjjxmW8ISTkGD1eyasrlgWVuqEOb19K1vxeIw\naXFGHxB4C1QEZGYyjuf/1CMcixaIqzoMgb1zp1gNHYWYof4wS8qXKmzkfiym\nc9tX\r\n=j9e6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"e479b68927b8c6c5ce5d4fea8e8eb4309e55e9ec","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.27","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.1_1567612569157_0.2372746287196721","host":"s3://npm-registry-packages"}},"2.2.2":{"name":"streamr-client","version":"2.2.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.2","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"941d7a9357da8ab5e22978bb15762b83ac3a06b6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.2.tgz","fileCount":77,"integrity":"sha512-EpzWVy6tTE1oLXDo7OmGg9c/MAfErLy+aYNj+nqRVTFb60k6NWNLJe3/gjY1Hnsx9cLCuW2arKme0EhyhxXeXA==","signatures":[{"sig":"MEYCIQDC+gsQjuHbe/cmbG0mJMJj2Z9A6FCwZUWMkTM4yHA9fAIhAJ5qnL+sYbZJbnWvLJU7G0pNiA07OMHls4h8nlg9Q+af","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4480306,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdjHbzCRA9TVsSAnZWagAA0mQP+wf48gb3Ax82etwQP1wF\nO0B24MVvy4rLj/fAU5pJwIwrSJbTxnkPksKsMBFJeUgPzgkuIOx7290R6Ixf\nmq0j38hA9WAn+YtMWmcX4NKWfli34PxhVE+hRDp9EuXS6T4wdqJudzNjtskU\nQDceT4MvHh41xU1iZ8UZWuQrF8QXn5IwuyjeTR7X8VHdowsiIzFBrvxX3Ke0\noNmrXI2BfScq61ao8WngtekBJkxPB/pQHWGwobJ3TUGQgxZ95DekhcKm6tsG\nHp3ywss/pHCBn3bMijFJUyBNn5r1npF2j5cZhSFsD94NSP3eIyWAXBcIhPDu\nYu9oOQl3dpPAOIkiIN/HfGMszKl3cUsrXoah0+KtKne1rGxHPQ73k+LxmE/2\nbyQTjXnmAAQO2yHgEYjMHYMHDlgBoqD9+HVHcBX8GGKSmhbv4OpVwzfa/SrR\nrVdH9+b38d/CpQ1dxp1bw3GiT7rfiqToxwX+vWfg9kFwkSY24Jb3LU8l0UtI\n7pBvMj8DJTZItHRd9Dv9Ants35f7RNeGnDFwQvhNLnLBNrBqkVER5IVOtN0L\n2h7aCc3mIgtya3Z0S9UrsMaBUHtsSGyzefW7CaqYfZ0aUEr8qDkupN3RAZn8\nKLsCPwm6L0izoxWEaBxE04/xHCgzVA+Xund/U0VM2gE/XBFV7IduXY6PteDL\nBCCT\r\n=9h9b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"7cb6790e2f53b984a2d8aa191ddda13f0df03b39","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.14.0","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.37","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.2_1569486578693_0.7708331823284464","host":"s3://npm-registry-packages"}},"2.2.3":{"name":"streamr-client","version":"2.2.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.3","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"cda9dcfcedf7f78a45a53baabe5c029fbaa645e0","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.3.tgz","fileCount":77,"integrity":"sha512-vE8/IStbpkIRg7fCd6VaMO96GocdPq+0VQltY/8szQkNGwPykdCwJshxH6MRzq7NN7KCwIwzBAay6yE9fZP+ng==","signatures":[{"sig":"MEQCIHdX7QvLaRSaDP86KKDzEplsYgmED9PegNdMO7VcMgVlAiATORBm7ypDLoEIE/47ADGQ5HxFKAFJ7dnw+oolsy2xUg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4481857,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdrZNPCRA9TVsSAnZWagAAuPQP/16ZfbwYcDliIGZmnlhy\nMITPFmyOJUJ4zScCECRcjkckvXUkCknZ3KRNIw4R3x34LiM0/ufUSIV3muYQ\nwlV/zF8ZHi6t+nW1Mgq660L3pxzeJlqNAPrQbfdlx0JLPQy/cdYihGwnp7J8\neAE4oXii9p1JI1jlv6TeMVRnyQBLrWDvbMOj5Wr6hiW46oC18l/j/4uBZx+H\nqTyHtARLrBs20I7IoKgd5JcAFZ0BZJC/OzaIrnXj/FGbDiCHNqCCAx11o37F\nsSxOwCEFc++X72Gjlwe5eU78tAbzKoSRu4gP0fLYuymOyA3lhPBgs2DZ+8yZ\nCHxN30zFqq6XMAR0DV3lfEtSnLgUFKTPZaLMjIW9h/we1hWZSxPzTGIP8n8L\n4BKA7Ye5oKNzH++vfPoTfXzieK68GqenHesF2sKLeS0ezjD2M33RGnWYS/Hv\nqltbmMQvAfY372K2h98utQh9iiCawLfnW4CeIqf3JKvKaWgSz/MuRVAMsvzY\nTb3zoIzAKCXZv9i9h1+YKhO8hLizGZ91wY8mblttDF9cTlrUXBB2gEkAl8bU\nSQ7AxyPJ4P/STmroAo/jmLJe+PEAfozEnm7y0Lt453xAAbkEmhFAC5uoKirn\nxYtZW72Tqj8u28qO6V58sDgjJRseT8nvumEZD62he6i1EDyq+N8IXo0UwGpi\nY9dx\r\n=+VnM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"96b4d326e60c63129cad9b98c9ed7fe74006d78a","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.12.0","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.37","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.3_1571656526608_0.9092763704037616","host":"s3://npm-registry-packages"}},"2.2.4":{"name":"streamr-client","version":"2.2.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.4","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"74344faddf0ef0664e2eab9257d8a1d712785443","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.4.tgz","fileCount":80,"integrity":"sha512-Slvkg98Qpnj5utVOz0uZsET3gA7qm4dLiSoVjGSApAjiG4No8rF+zokFK6D3eBdHpcYPCbNKhyGBwOnlIo7MdQ==","signatures":[{"sig":"MEUCIAwMvKpIU+EG9+J2ArcsH7C5YRBDcOLE+mpU2Uddj16WAiEAmG9QWp+pBsF5Xyup7BAXkIyfROOchzQHJ7TSjpF4BEI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9318029,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdsEthCRA9TVsSAnZWagAAdqYP/AvZkdhAj6QWojxfSvEq\npc2DlcGd41FpV0lHdSB6VYo3i3FFZzNV57B3+6l+yZRh+u2QOHp8TLlC8omT\nwEPN4hG7KFdjiyVnNgSqUc3HNSOEvhViVc0zKlomns9sYn4TRjYOMAgmgH2B\nxfojDjOw3iktn1sts7uNYW47SaflEj78V9V8slixbYRAIZGCiO3DOra44JMb\nRbljdncMshSZlXAI5Ca9vNdbvsPnF9D5Y4j0CtrOQ6r3UI4itTwbgi9uLKaI\nJ2QW/t06t+usMX+Xq9rvVdFOwyMudfE6uBAZraA4uH0ADBkFDY+vrb8RWgNk\npaX4SF76kZZLzHQ44JnUdkq6Kx037KF6i+Xcbf1UJBk/b5GchJPK1ndqVG2T\nFP/77qz7Dx0z1WSLCf530S9R3V+pMYhsGCQgoCDYjdILwMeZPLZBHJl5kwNe\nlrcPMQbmDDoZ6RIzbc/fMac3MFzg6hVgNlz/D9/zZsYbhMXIb/HeulnPkVCC\nDu7u6x7rAmj6CRgOh/uK47vbZqh52tcDurjwS4noO17xEoag4DxF+5LNdp/S\n8y0y8kF8Ag3ybDKJIpIaRGEG6dyb/Uggqme3Q/3zHKQ6/6pup81vi+SAj2IH\nHkCTQidp/dpUozqWvXLFwM+VA+qyKivas1cVyIzjVTsuHJEOo+0eQx+N+o3y\nNyiB\r\n=RlhM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"51d0382dd9a8b4743b5df8aa9cac3aa708d78736","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.37","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.4_1571834721122_0.30747960115580897","host":"s3://npm-registry-packages"}},"2.2.5":{"name":"streamr-client","version":"2.2.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.5","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"cde9201cf414077b871324934c4ed7132607106d","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.5.tgz","fileCount":80,"integrity":"sha512-3N2X5wn37UnNNJ0XCy3G0FTeOc5MiiAjC3Eqg68ZZNSu/QclPt/5A17ug/2syyp/yMr+9XiP8OfXcZrzxgRxfA==","signatures":[{"sig":"MEUCIDIqBWkWUPYOdkhUjrRIRN8mc8lEP5WxklBO0qnwczsnAiEAqa0T7p2y3P7Z2+Bf1ldBKqq8LjA3b3d4i01tmrMi388=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9328667,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdsJC/CRA9TVsSAnZWagAACOoP/RPhL2KcYfbtiwbO32+q\nIAiquU1gdsUARyqrlE8MuwNA6rVXyk+3GkRtaGw0lS1DfOGmOaQ0oW49LskM\ns+HeZ6gtITTm1g+WDqaQ+3O5elETBUkRgCy1+MG5AGmu1pdMKCn6d75sMRnB\nsN/OE9xFgfgWO727W20PEi/ilhb34vZeHtEJEIISIppcyLD/e5zumBvA+hGX\nMIhKQFxkkt+0Nla6Lx7uyWXuwHf9Cb4zcpqujbarrM/SHh0/PhbGMYgKIHOf\nCcc0jU5ZkyjmaMHHZPITlmeOkf7SOe47DXjxtzX+mnrqBeYCLfgc+TClG+DQ\nxBJu9erak7vBmPOvbefqYINZfPGDYxPRxJFjGLpKvcjXMhWLGwSYI9ZHR4XX\nArx7DKmXfDiUEFYXbPDWcn1esLCd28FSV/uAstgeCOH9QAW1X7hj3Pj3w36l\nsEDxkj88ipKc+PG4jjpMhwW4DZS+hmDehim52jiM9O/ik3j+rz+djEasK9vB\nYX2J5NCdi3ZAUOzP6U6065piJDfH+uSzayQBKR7BmqBZS++Z/1WXPTwUsY3d\nYmVlaeb/5qzWqBmXcDPGXHFtCTQjdJojTqY6WCbTl0pTv8HXUCP0LbxhFdQe\n2ezJP6pLE2ybX8Gokb64/BaCXcDMQBiorLu8pGNkmm+KI2lrKcGmE/pGnQ8J\nymC0\r\n=BhNS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"270711b12989779a9dd30fc76fb9c2c7be450372","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.37","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.5_1571852478957_0.2977247776404006","host":"s3://npm-registry-packages"}},"2.2.6":{"name":"streamr-client","version":"2.2.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.6","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"94df1e67880145b82c2831dfbc64e0f8c7abfb0b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.6.tgz","fileCount":80,"integrity":"sha512-FPohta86yr86bsm89DABKgUMi6SQ2K8XU30U3MCKZc1tnTLe3rXcCUbeC4V5tGQR59BsOiA5wTBMvo5WKK0ljA==","signatures":[{"sig":"MEQCIEgpkmEmM+uU29DhUFONj3rPdSwPb2kEcmSC7/y0e7BSAiB2m5+CykBKkjaCw+CzHT3hC3xNkMFFe348ao9mWK9J7g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4685729,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdySCUCRA9TVsSAnZWagAAig0P/ihKKK261JSMTQwRuRSs\nbjAcrS9eYprYSLikFfRuClESweKT62dRhLEDf8/KKGhCizRs4fl3SOIovKlH\nGY3fTFWDJ88e6i8F6GpgMsYSnCyXdeWTHJUk4Zm76Cg8TKSxm6dvb+fILyno\ntUBPSc29I5mFHK4yY3m+EBV6qFlV45WVtBoPFmRbITCmqmaFiKLcfrW4mFa9\nni6sLlb8jOeQT6ck9JaaCFuA9PTNJRwsQgD1TV86zHw7QND9KPPOAmU3kscX\nZ840hBQYd+FUpWKd+LdVS7+tdPOJWgyCCnTbebEIVs1QAx3lJ38qk8+hKZ9u\nf9LE+trhKFfT67Fe1JjarSfqRohBnVw3Zl7n/iQkrT3nhjBDAx52l+pL/cWm\n0ADD839V6N4Cf6E83M/zQgjyDf6wcHcAc7A9BeBo9bth+XoQYO4S9T5ozEqT\n7jGDs8ByaVhozjMK1Vv+yx6CKzQGGuGIbLVhGLzj/bmx4wWdaVtZLzjlQ8mb\nafgi4pRYK55+LrkU6HuJISz1/8LabDwiocvz3eJ4mC5SN+vT1sHFHUm6uZ2I\nomUifROz12xdzy8eaxxmR+v0W96XkGJ7hDlslzM9AJnXTVpr0lKt3LtEStuq\nDTEMl1TggUusTNmLHuafRnjWD1G+dQ8xDfYFBXUCBi4HebWgRuEIOydU8D3U\nWRsw\r\n=zrQi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"c0df6073a39ae1ff9da9155349023e5262c95046","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.9.0","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.15.3","dependencies":{"qs":"^6.7.0","ws":"^7.0.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.37","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.15"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.2","sinon":"^7.3.2","eslint":"^6.0.1","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.6_1573462163782_0.4760685756957259","host":"s3://npm-registry-packages"}},"2.2.7":{"name":"streamr-client","version":"2.2.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@2.2.7","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"002f1930ddc9b2ccb7fa52f7585c59b19153ddad","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-2.2.7.tgz","fileCount":81,"integrity":"sha512-kuML3K38sbEaGTXO27IMMJkFYY3JzVGwe+7ShkfnncBIVMlC4dEvV+yIxta2Yi3GFkMcPs0b9EdaMAScoZssgA==","signatures":[{"sig":"MEQCIHJGJPBnFZ3XRC3q8vzFgWQ1EnQc6ewmvlzUeDWPQdt1AiAJflzU2+pNG+yB0iN/HWobYuuqsKgHzVhfpkvrpHK8Ug==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4692545,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdzQnUCRA9TVsSAnZWagAAhNMP/0MQ2zetZihq+zJM9PRF\n4O39fcW47BSmtXbwtBJs6CKgOtuMXJtEv2gG7uBMOPIbNUPrxDv5DSIOvL/I\nNADmloOaaweo0rFt2LeWbNM9mP6KhOLni+B4Qmexz003P9H/yYcRhXhWSVcY\ndGs+9dgRIDL9Kj1VUqh8Vjh+ojrmFcOulImo8q155ZC43BhumwcTMlSHa1/V\nwI+ee11F0e+vtSM9TUJksxBliKdGJsdH4t3ceOANmGWeRlgZoeIL+m28n0eB\nSCkW1LY0ikM6BDsUUm6+YVZ56Cz/q663SjCIRnpLMkqMjsEzDUH6s23Eh491\ndAWiyXEAKqPZLdTfkGOkaom7tW/0M0bE84xyj9H0JcW5zCXgWPRDut+bSFAB\ndOXa3hEQbfyg2CgD5jggEUPWlHoNAwnEVDAWZ0dQc0Jlm/6K0BoQDkXPQCWP\nSro+e+qDU54t2R8KTJP1olG0lc+tJcoNArCKTISjcuFH9uAthnKD5m1GBApt\nuCgY4ipek66eTgTQP+qGW4jl0fmi1CnP9G5+4tEdfxWFMO++Kv9rWKzqL1yx\nWO+OH+DrDmSWcqwVzKGWTWIbXjqo9zpsQp+nJB+6nYKsvRTrwvM6vdxkV27C\nYulZhB5Isf3tnGPA7wKwEDHJihh6gXd4Rubpnpnc9pV5dYBZJlxtn7c5HRBf\n04F0\r\n=2Z05\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"944d04594dd3ab52502ce15e39fa73644e305bbf","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.0","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.17.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.0","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.39","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^2.2.15"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.3","sinon":"^7.3.2","eslint":"^6.6.0","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.2","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.1","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_2.2.7_1573718483506_0.7673672134783747","host":"s3://npm-registry-packages"}},"3.0.0-beta.0":{"name":"streamr-client","version":"3.0.0-beta.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.0.0-beta.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c704416083f371201534d98087f796a80e8e40dd","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.0.0-beta.0.tgz","fileCount":82,"integrity":"sha512-yktcn8chYh0vb7RQC+5k4/hZvRRykU5QaLq6ahMzyG0HTuUtTcKMlY3WMsif2MjVR4ZMyoMS9nMEuK7Mg4Yq+A==","signatures":[{"sig":"MEUCICuH0RCIEZa8ouzzRYRLLj5jgbOPAbK5RA1qteEg7R1IAiEA4QT6IZIJmARwAtaL3xla7g81o2hglYDwuU1RvPQlGgs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4719117,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd4NQeCRA9TVsSAnZWagAAcaQP/ja3bC6lBjEB4FLuzxRI\nUKNSqLzUwg5SGfeI0ZPjBXD90iGwBm2Zr7+yENcEyg1vsAvGZ7muc4owYZt+\njSxRBjpv+BL/JzqEPlZzY2cF1oc/fHXYp2JW1nYo3mwCvupo5Go8FS50Fwam\no/DIcllz+142mGYyXAlbpUy8K3qSwAZ+Vm7SxpNx4hy1XTzXHEe47FpvIl1Q\n8QNUUY2fCor1nzh9aUX2qGvaplZLsp46UUBMRx7YI/a7AvkSzPRzEzHleqsT\nY2WaVMQD1KWkUfLYTVfFm1AXwbB83EN8FxWVTEv+7kbdsNcLUfovO8JDONiM\n6PDVMNQ/8ece49Aasrh9dNADG+jI61QK2NBbtdl22OEXGUpLBVyX40R+iqEw\nQhD1LvNE8P74gppEaQ9FdAQksZZc8tCTWiIjPoxB5FX4SJoS5f/2LljVFayU\nZG44K40Ov/Q7AvHh7Q2DVBnSLTraMfA99EWcP/qP+/iZfGum0xTATyINdq94\nSDiEaTHWQxHZfzz1H8n9tJ56lU/wTEw98O85JDlM1z+u4eSr0xROcckfCWfY\nnqkQjUEctas+g0wqQV6ZDsmQ82FpjSwiLIxfRDd91TayR9Q31NsMlfJ9f0cD\nyxc3NgDB2RaC6NTfexMcx6l93PdWSWsBT7nf+gtK2Fk4vY1GpCRF8lshW4LD\ng4Nx\r\n=jyIW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"7f2d269764ae999a9a1094490d9a6c42a6ee5e45","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.17.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.0","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.39","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.3","sinon":"^7.3.2","eslint":"^6.6.0","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.3","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.0.0-beta.0_1575015454283_0.7020664394270619","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"streamr-client","version":"3.0.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.0.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e5da7edde8bd7ce16a199f56db543b954989ba6f","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.0.0.tgz","fileCount":82,"integrity":"sha512-/KFFI956SjfVDIFrCcZcpCj3aC4973QjtGLC+68Llan/hqdZOKEbd1wS0msxS3wyrDohUpS9vWube3qTCZDHAg==","signatures":[{"sig":"MEUCIBcPi9fu4aQa+SGXUTO3WjU5lu84NqcGEXkkeowI50czAiEAjQ0ScXMwnhKWTMQrF8fhDNv1zqZkVpGEOmosLC9KKG8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4719280,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd76XVCRA9TVsSAnZWagAACNkP/2HRT+dyJeihIyMlttCA\nicRIDywH1aYC4D4eEKyW5rKOEthLJp4kad/QYd8ndFo5GyTtKYYA5DaYZzcM\nQ6M05UybEMauznCGtqYT3PKWyq9ju3IYlvWMv/96Y5OD1T+LVvTPo1Taypaa\nlIU/sLUF4aDWNiXri4e7kpkT0USn8sonGWYp4dnJ63D5g4cVYiFX6x+uRuH9\nd+Paj3MsDwf2FLAz+nnUSc8/nsCHTCNA0M8bhC5mxxZfPQq3QSZGM4qi2Jh9\nRXUDxZqJYvZDHrJko1WVB8yCSaLz4j7PFRnVpFViJTOscTJy07PI120N5rQF\nByaAq94/HkBRzyEjRFI4qYQM6ZHybMjb/Ckmlb1eRbrCfZKJDbPRtmTIjXLJ\n2NjID754spVy4KTgOrH2nZikYDPCPxlJmvb5cXafTlKHB7cEzp3Jsr+yZAvg\n74WC3+1h81yeb9a76RQlCgfHmzHQqz9dX9WXDFR+LBDo/tK007Sh9MsX2lbd\nixqJ3zYKrUa9gwVVRFH8TsA6AkAQRYYgL1t1c19LE7Z2oLBMfOFiJdtt1NiW\nHejkH+MerSVajtY4PXGuzRscNSqv0D1Co+9kUyfAa04OAHS63Q6UeR9Suaxm\n8xzt+hg4SYvsEDlBedEcPmlatLVYUdrzrtNuUAgnTJG/cweuX116CZTlyv4K\nMAPI\r\n=Cwld\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 8"},"gitHead":"90401de89fa69a81915bfa9d18f31f8b3e2d6749","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.17.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.0","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.39","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","babel-runtime":"^6.26.0","eventemitter3":"^4.0.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^23.6.0","uuid":"^3.3.3","sinon":"^7.3.2","eslint":"^6.6.0","express":"^4.17.1","webpack":"^4.35.2","babel-cli":"^6.26.0","babel-core":"^6.26.3","webpack-cli":"^3.3.5","babel-eslint":"^10.0.3","babel-loader":"^7.1.5","array-shuffle":"^1.0.1","eslint-loader":"^2.1.2","webpack-merge":"^4.2.2","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-2017":"0.0.0","babel-preset-stage-2":"^6.24.1","eslint-config-airbnb":"^17.1.1","eslint-plugin-import":"^2.18.0","terser-webpack-plugin":"^1.3.0","eslint-config-streamr-nodejs":"^1.1.0","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-transform-builtin-extend":"^1.1.2"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.0.0_1575986639923_0.3837730806128905","host":"s3://npm-registry-packages"}},"3.0.1":{"name":"streamr-client","version":"3.0.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.0.1","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"7ade4e86a57496ab757e2539ca44f57dac078764","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.0.1.tgz","fileCount":82,"integrity":"sha512-SY4GMC4eS/q3obh8xjWrm5L86a1SmbyTug+97xf5/RB5tTYWzsCDfXJ2fMbTVwzwnxKgWxXFm72HoDvbVyQX1w==","signatures":[{"sig":"MEYCIQCPFQAn0vETYHBpxIdHkBWCY+Fd2kes3k8ZKeAcu1IrpwIhAK075F/zlj20NZX6RDAWmoSk/TIB7HWrXmLcd01ixD3j","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4687152,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHCrnCRA9TVsSAnZWagAANkUP/0JX98Tzq/daIzG6+5GH\nNsbI8a7w4x2yhNkmTbLCZgsQQYNK5rLA7aySgGePpjVddbDjS9xsERz7WFgo\nc5+U8RBCBDS2e+4f+yjpO124j3QsA2VBuK6sPIRJtDm8qsleXfqhvtUekgfX\nZ8wE4gC2G2GaDx+XgEdE/B/sZq2JhvjlUXtjOt40Hpy3RjTdiGZcE3i96Acq\nukAhL6pggACBvNk7wFn2bRBvcr+rhqypSFTgO8xqjtl5V/cGfMhp5n8I+SwD\nAYRuxykv0tffuhmgNGaRDpeybCZV2azS+q4TjxCDPPuoVU1kMbiIw2tVfDvJ\ntRLmFQvCe4LzD4Zl4ZOqV6rxBccUG7Op4Ce7sjxjmdbUqckmZuJCars4do1A\ntzdNdFJvnlHKY72NBNtwwCCyJ3ilnWJ8siEx74LEu5YFt1rA4Kp5XO9Z4Mx8\nmsIk885q63XyR5xYbjPKAnmmoHK0MUQorANvdvfjziSvXieGykhvyYdMZsk4\n1ZSWzx4mEzWWqg92XmAElWW2soC72f4WbAXb7VWpgD7oqtsLznNM0L3QSVQG\n73sRPaFiZmzjgNdIbwZ9+dWD20RoQshS98OupUaOH4Xaw0wF4dW95F83Sf1A\nFnS+0Vu0rwuZm1hQpG+gaY6wKAlip63St9FkudJBQI/ToHA3TDMMXeQpEYGE\nVu6e\r\n=HhV1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 10"},"gitHead":"cf5c4db54373972a635469a4c2cd5a7fd5da1168","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.18.1","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.0.6"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.0.1_1578904295297_0.7514540269952328","host":"s3://npm-registry-packages"}},"3.1.0":{"name":"streamr-client","version":"3.1.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.1.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"74def405e2381e3f675fe6a50b6ca40b2fa95a85","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.1.0.tgz","fileCount":82,"integrity":"sha512-+nGcm+Pj0I+0xY9GdSyMm8TNjcc9VP+ggPNxwALMc+Ju2l22ZzNI0wkgcA8qsP7SxWyNWTbwSeS0Whp9FTSysw==","signatures":[{"sig":"MEUCIBnCPXsOB3RvxwzwFWgHf5G1FFWcQlAGNNTTauP8J1YUAiEAuSSvEAj9jcFdHWw/35/fQ0NUNp/pr7I05IDyoNbYWGM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9276032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeOeZyCRA9TVsSAnZWagAAZQMP/jXzVHMYGzGwrBcuLR9t\nxd5IhavrakpVY0UiK1cOzn5g5XKP09qpj9u4/BekDXfbmyaA8WTBu0/7XsEl\ne76Zq+JwoBLqzLAaGESrx21PqnhgN5z3iM1j7PSa+9Ja1lIgbCKHkPH7wMZ0\nU9mSQrorc6rPWELKa57e/2F1ejgJ9KI8OHAWDy1fscJznmPLGW/NPjMYIMVr\nM/hr0bH94OZvFKIxBCYZgSTxQ3ayd+Fmk4799z1U9ym1+whcOypG/K3XN+Am\nZDRXyhOfKixo6CYNj924eKsD0xbJ6Y8wZrPysh4OjTmTgsDKG5KavAisHFuB\npa3whQ/rP2e9eJfUCc4jPQH6ErkhLaDAgFV2mhTwSBdXneVL5wQElUfO1IrT\naLWecd5ZUxpc0OkjhykhsfQLDA6Ghx+YiPXOYc4yQAypWBD7/59UMQPUF/W0\ngoC+MkkN/a+GusDEmdakeP7dFNZnZQLUcaU+SZNPr/W3mmL2qHau4zWNUajZ\n+c3Sj3xtnGwixLLakHtK/nkdVotkBj7ZlXIuzuDiNkEu3OImXr+/ZG6Is5cc\nPhBPBeo4fkGwr1vyt/v+zuCsDGwkih2bDGWoea5OOdKynuRygCORsrcHfnGV\nUxuwjAAsoU31EAI8YMLMQptsAbEoIM4L1nNQKzKR+0GY2WQ2isrDZPvbTWrV\nBMGU\r\n=YtSv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 10"},"gitHead":"0005e424b899abf104442ff76d219f7fa093d1ca","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"8.9.3","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.0.6"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.1.0_1580852849892_0.7839719257568771","host":"s3://npm-registry-packages"}},"3.1.1":{"name":"streamr-client","version":"3.1.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.1.1","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2b3002ad24839d9cfc13fcb95eb243fe3cc3cf68","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.1.1.tgz","fileCount":80,"integrity":"sha512-hkAl/IrQMbSJzrFggq5IYlD9NHf93rCTZLPkMoA41LePFSKNNKuGk+hEniMVDBAl5bhBRvZ7ft3mV0599zd+sQ==","signatures":[{"sig":"MEYCIQCYASJzeFJjFC33M5y7D8mdxOAG9Y9hqM7mcSZpCPtS1QIhAMdVDN8EPih9W57Rm6R0gZtxLrSZgOPDIgnOBns9Xoo4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4449451,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeOt5YCRA9TVsSAnZWagAALwsP/37aWvDaeOuKdrPLCG9a\nrTsg8hMDHlk1SFxsTXKah07qHqSSp80sn4s9OGEyqiBUn/eHzLkLNOgEVUFs\nGkrBFV3H/m34HzaIJd33bovlwOL7gPf7rmEk2apaH4uIdLYF3GhVhKHDXMI7\nORfSTkJQdDcshtFETeY/J708kZNMN6Xb1x54OXhcBKv3DOyo1kqFsm7VWGD1\nw0BmwYUizdRGRBH3RFsKaRHXsaVo9a3MfuT5dcshOxemYAFZW8CDTlUdzudi\nsVHtNHIOTMPeesUa/GwRSjrR5mR8OvuFhXo10qE9HxQtSMRuqD+/7mWO4GqF\nlDCvJcigFozb9nwIiPau1o+AkwxNROITypDYQUeA0LXuJxU5V1l7RIyQJfAA\nEScrUAwvCAMyZMGEBuNZDOHjUezItBWz8bB4Qe7DnPKApCkMv7qt1Bxvfxkj\nl1/nQuAd8Pt3PUG4faaissKc1eV0ASnlephxKVUNfROVMFGHXtt/X433YhyH\nR2o6syAwS4ia78l5lAN6ktXOOuHSHOfy3zp5gOPsVmoUGKFP43TzHXlemWs0\nnOXFInEJlNjPvLDYBcf2QS3mAOp+rGFKZqJ+oWDXaGbk8/a+ZpYd2iGvgBoB\nJQGiXXH2WgFo6e3L7B5KU/dkbuzyTFObr7VJXAcK3IiAb7bfQ0Ip2sUAO3l8\nb7hj\r\n=++QK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 10"},"gitHead":"5217fb738933b48be670dc522b98646191245eae","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.12.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.0.6"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.1.1_1580916312091_0.7215038988296198","host":"s3://npm-registry-packages"}},"3.1.2":{"name":"streamr-client","version":"3.1.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.1.2","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"62b4bd382931f74a1bb82ec1ac6e037e0071d764","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.1.2.tgz","fileCount":80,"integrity":"sha512-TNi4Ho9AB+2K9GJrq1D2oJeqGL+XmcuXi1kbHiksC6P54m7cqoIH5dceYtIJ5WwNb5J4TN1F9AfDjF6nruV/dw==","signatures":[{"sig":"MEQCID5JjE7e+pEcscmu4E76r9GtRGrWnbU68OHN0wdZocbtAiBsYmZkh6oZv6crmrJmcbZIr9Z4RkuP8SrJQrtZhzJSvQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4452319,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJePA9JCRA9TVsSAnZWagAAlNIP/R9lH1fL0MwJEGsAE+3F\nnQj+DWnOCC+Bi9M68MTRrU1hEVAuQPELJxQcKyOr6BWOB4bZ3kxTo6liLn1r\n+ij+b7STR+glOQEwMwBgIxx5Z3+eFCm06JsNSViQn53OvVo7HXk8VtiqDe/l\nVvDvj3eZjicKr4j/IYiJqF75LK9B9VnQfFetToshny3EEHvS0z3ck5BhmPt8\njaDXk02+uytnkRadTE9fzvSdvnueOaU1PgXjgldXegmYJU1rfQbimGQVbmng\n44l7Qmp51u6Q03+vtFtZ8Wuh/tp9rVS15ELjUueSl9cZ8vGG/7Qsf5D/A1w5\nbSyyrCHLS7E6oMT3t+ADP4+IMNzZCyjj2meSEyzlBTUAPTKPNu+7+AmN8iwh\n6bAhD6yek83RPjfDEGZRIKtevot6gseuGr8hONlcg7orzpA7HpWNZ20jrEmL\nwr6p2cnSM6qyF0l0eHGdpKWgi82Is7JY+leZzQB46u8K9pREwqn0EBT8/pw4\nExeHUHKAZMbtDyNBc/kBy2REH6zu5opzNuKwJySkee+crC4kKirYOf7V0Ivg\nAxtcEfBi1HLl6oUQ3NKqQJx63L6lmyKOYKoTv2Mk2CKqR7NAauceQtsBX+wO\nzfCRtQCkbHDqUz2B3h1Bp7owiL4V5i9q5SsRKSybfUUu3qeV8RDAhM25zTD0\n92OF\r\n=SaxY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 10"},"gitHead":"bddbea185b44dc8447a86941a75dd8563797898f","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.12.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.0.6"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.1.2_1580994376649_0.9821939830669673","host":"s3://npm-registry-packages"}},"3.1.3":{"name":"streamr-client","version":"3.1.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.1.3","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2b0ac1be1c988871e1aa428f7427321e09cadf32","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.1.3.tgz","fileCount":80,"integrity":"sha512-IKnZAbyKUtJU107SYWQz2K4OSM3QFI5k5OXCVrcsWA2SucIXJ7OFJN+hZswN4oGFyEwm8DAoJNaSF9dmEkRp7w==","signatures":[{"sig":"MEUCIQC4LJM6SBGyQ6uRC/FLkRzhdzg+q3ipgyCpls5OIZknYAIgVgmhx+5P+/d5Juml30PJlHe31Cqgj+EkyyA0zrnruwM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4459687,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVn7YCRA9TVsSAnZWagAAJL0P+wVyE6BaNYGeqxTi9D7M\nlsy3roc85hAwHmFt7TMjCkh6vCYUlSrsB/1auZFBKue0xkMvK7jP+crAeG/g\npNAucTdXYNWxeStOsMuApNVNow2OUJEPJUf6vX2eLwS6TrdVcLpEsxhnZt0o\nwBm+pw8dwKLV2wDwch72kv8TqWa5vmUyRG3TjMPO/yyqsU7pAhIDN6xCK9ca\n9LWIjKoL07oiX9F8dFywcxQXGALUGmvypKmGAkeG1MOWMLXCbLPhrsyxDfBO\n8n89w98ex7tVYpbdx+4W7xyaIvYZA9rDRBSxno6uVa155Mfd8SwcXxZCJiqy\n7VqmPC6M9KR4gJ/6X8rFTG62yLz/hmGXenTtPuvdTRWODfY455iOREa0B2XZ\n8mt8w4/M/Yu6o/RjD4SoAo1r2T3AsotpfAOFZrsX64sAu/sieeQMl7xGnY37\nk1k106PuQPlD2ImTYT5DBfRAkRZY7ciYpzrhIsiGDtXu1LIDy9iee6O5cYby\nkr77uJzlSum6IdkammSrklEUEi8I4au930CRzAUZemq6Gwnb+FgR+B5ZwkCq\nruLBYouMDGX8n2vCzfmHcVyN359b5IodEDdBY7bDpltiEQSCV1qPPkk3RTZ5\n/TRwKclQGWfWTDNCaPryKKfVZaF/w9X9rXXeI5rYXcCS3lGDNCppk1oH8sOz\n5hus\r\n=ICSp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 10"},"gitHead":"c43591d617a0f167d82d44bee477a780dac3936e","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.12.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.1.3_1582726872066_0.9465377429334842","host":"s3://npm-registry-packages"}},"3.2.0":{"name":"streamr-client","version":"3.2.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.2.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b3a93d349c41c602716f78c57cb024136a3e3f49","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.2.0.tgz","fileCount":94,"integrity":"sha512-8j717u+QTXWTRKCHk+WmATiziN+LBhQquUhovPM4B4wXXX/H4W9KtchkTScfqJwmfHynMFAx8Z1ioGBn59v8OQ==","signatures":[{"sig":"MEUCICrg90RXYoMh61Y56hC1+U69w+8afnmaGb8n+oQ828PrAiEAuATVyy4gYXp1IGdp0UjnY9OTiqS7Q5DosXywplsn7gs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4789076,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecizTCRA9TVsSAnZWagAAWFsP/RVc4ZLca5zCiqcMD0Kj\nrPtQq7Vcr2x2BYimyCQp/77lTVGFbu/1DUu2+00N6wgQ/n3k8WgfIKwQJa6J\nIfHdJ2c3ru7H+ZsyI0JWnloRX88cLH5fJI847mnXDdCZpvDxaDvJCpJ8uKdD\ntvHYqVe1QoSdHxXoyCz6YNNI5OtPMkfWb1l775dOWqGzpxeoLzpoxxs5l5lD\nQSBzBfywIYjco+w+RPmaIUKH2CvRyp3kv5wQ3h4WQsaOHNu4PTV+NjSXQS/q\nFjnV2ZVeuaqRxRnjtjlvxF2WtlY1vjLEoY4WM34ShwZW1DLc0gTKbLkiLpWV\nlEKEcRx9JZZstTQ/oeEoXQ4NwGr6KRKdk6OlZpPdLObGXVeUefxi7dOTiOKN\n7fcRAVybFbP5H8nui7A6CFVhCz7t+zfEaPB6pBpYbqo+Xmwa6cCeQ+sHso7N\nk4L7zCGtJPAEmYurX5hJ8nCdp/Kagv5SNjFXQhZ+4xtxopWDzeAqutMhYQet\nfyzbynMenMBpZazODNBa9kq+6dnWfCsifByzB5BE0GmqDdZ7aaHgXxAhfybS\nXQuz7b5TO4U2bC1snA0v7In+AkwUHv02oYD/HiixI8x000ElyfKzhBIGX7xv\nkUPSia/hJwclAPGug3nvTakct16uEqPM+Mizh634tlnbZsKODN/r5gRX7748\nbsZG\r\n=By8e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","browser":{"ws":"./src/shim/ws.js","http":"./src/shim/http-https.js","https":"./src/shim/http-https.js","node-fetch":"./src/shim/node-fetch.js"},"engines":{"node":">= 10"},"gitHead":"a395d5d8f1b1995691da1afb10cfd7c928214701","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"Bad build. Use version 3.1.3.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.12.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.2.0_1584540882586_0.450463234843304","host":"s3://npm-registry-packages"}},"3.2.1-beta.0":{"name":"streamr-client","version":"3.2.1-beta.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.2.1-beta.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"85b7b353918f677298bc39df3192c47230246647","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.2.1-beta.0.tgz","fileCount":101,"integrity":"sha512-8o1HYXQo2f9EI64rKoaNEz3GMwLZ61N1cAq7q03f3Tbn0lspLg3jPLXZ3EcBimWs/0ICjA66YktNhy0wF7/AMA==","signatures":[{"sig":"MEUCIQC0p+aciHOyLQ/kaOzoycmqdijHO8tDkYWbkWYWwNjMpQIgbvcMQTU0boPweFnuDUZjNpROPcTYwlkfZ1rSOqlN9PA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7877784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJemJpbCRA9TVsSAnZWagAAodoP/jy+sGI1SGEik2ZwnoqH\n5HrhRFJXkoD4GfrjIUDLFoPrhaKn7ItAeaonC0t2znyU8NXs/1TSF4DKdKok\nKUYsI6K9KqDAXp4+h63/+F+lEnc4L6sVjkdIoORKAj74Tfdh5wFV01bh/9NK\nE2iEqJIL8+p2SAcwf68HDh/RAAwIgII5mToQ24t9/P6UaSkQjnBW741znj5L\nOIz21OLMKaencJOxoeFsZQC/+degSv3P2dhLa7+2auJcozd/8zuMJbSfelwc\nWoyvDSvQW5wq7EerwoDNVwjHaNAzKoRgpkdf46dG5ePkRDPX8sPtbgdUN8yu\nBa7lCT6D3WXvHF/RvCUJDXN2Xk3pTWb2tC/XMwbAUbbwjLZqU+/oJlKn52bv\nN/8wxLleyDm/47s6nZIdW7Vq7xzhIHC4FrgrZ86wg9gqLoCoOfZoAMnhPSwk\nNgN37QUBlza0JyoU87MJTYNDSxZQQfAD+b8E3MpbJvCsJe10cmFSY3G5xYns\nrWT7uTP6b1tsqslTJbeUUZIURvEfrcVp6FFQUwnkNG2tI7F0zc2pVq9nNEVG\nOKsP/MD085xHg5DAQAZ2eSQ85bhO2SmBnDkqeYwdgKn5rw1Pgznl0FDUILID\nbUYemmdur0W52h1PcwFRPbzaR26Z9lQxPnwwJo5L4RzsVKoZUoxyR65wIaWL\nfZq0\r\n=g3iS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Community Products API\n\nStreamr client provides functions for working with Community Products. All are async, that is, they return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployCommunity() | Transaction | Deploy a new community product\ncreateSecret(communityAddress, secret[, name]) | | Create a secret for a community product\ncommunityIsReady(address) | | Wait until community is operated\naddMembers(communityAddress, memberAddressList) | | Add members\nkick(communityAddress, memberAddressList) | | Kick members out from community\n```javascript\nconst community = await client.deployCommunity()\ncommunity.address           // already available before deployment\nawait community.deployed()  // waits until contract is deployed\nawait community.isReady()   // waits until community is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinCommunity(communityAddress[, secret]) | JoinRequest | Join a community product\nhasJoined(communityAddress[, memberAddress]) | | Wait until member has been accepted (default: authenticated StreamrClient)\nvalidateProof(communityAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(communityAddress, options) | Receipt | Withdraw funds from community product\nwithdrawFor(memberAddress, communityAddress, options) | Receipt | Pay for withdraw transaction on behalf of a community member\nwithdrawTo(recipientAddress, communityAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a community\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(communityAddress[, memberAddress]) | {earnings, proof, ...} | Get member's community stats\ngetCommunityStats(communityAddress) | {memberCount, totalEarnings, ...} | Get community product's statistics\ngetMembers(communityAddress) | [{address, earnings}, ...] | Get community members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"8bf6ea859083db099b67508f4bba222a05df1cf8","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.20.1","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.2.1-beta.0_1587059290426_0.6543774003374354","host":"s3://npm-registry-packages"}},"3.2.1-beta.1":{"name":"streamr-client","version":"3.2.1-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.2.1-beta.1","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b555f570790676f26c9570a843bd8b4f53e04bc4","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.2.1-beta.1.tgz","fileCount":100,"integrity":"sha512-AeHBsGG95vzNhk5K4DMAanMc1nK/vB6IcpTNsXCz5UY3OuNrLFsIneEl/QvOKGITiEScNBqGupvQO4/8XYtk/Q==","signatures":[{"sig":"MEQCIGLEIhJBPnyzyPg8yL/YET+zyOXk05SRHUypZW2J15MeAiAiHFJSdCZSK2MVsrne6b1b89L6BeUUYAZvIWj02drpLw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9727585,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenW7ZCRA9TVsSAnZWagAAPfAP/2ZC893IcmBTwVPihmbf\njFSfZeXxLJ/vrMKaRZhYbjPIQsEV+i/LzQH+2Akm9jSbnfhe+zQn0xu0KW6Z\nwvdq+30ZI9alDX4hofBZ2BhipZvYAlZTFNi/nRUhLIAaMkBiEaHcmF+wF6Fh\nkZ4F49HJdfP1w+IwXV67s/Hht7y58Hi//VOCjDrbrJKxZZoit52S1T+d6k8x\nxKRSgTw/z1e5y/XE+8841eJtyamS0sGfLVdGgOv1SnNK8Q1ZnndOhpR8MXyz\nviS+jFh6ZJRuQGhlFAoJzt5gxOKVhb9PjZ7KR99vLCj1276MjWdY9nNGiWpa\nBP6moz2Ae4wulSH3twRlXdWh6J7KgmjjD8UF/gwlKBedwz8MnGM8O/07Hu8a\nGs9fn2re1Z0rv9/jjPD9rWnQaGdmAsC0o2GnFuf8grIbBtCQwS8ZCwrcQPs6\nbjCA1KpNkbGMHBoztUQEGyVJFC9KqxnxLvcZGa9RNl5LIE55lDnGi5cAq6mj\n5e6cRiNd77xYWtz34aFlV49sGQmkN09plRo8rpA6vm3PbOz4bJMRVHwhetKp\nYd/EagLoFBE+uRwzjo3AdP1fpMxj7i4/rnJShdyJZxa8Bfib1qUQbkMFAunt\nQyEtbtrnMxBlC6Scdl4eysVHWlMnq5nzfMzRPLoKB5nWYlfpSMw/IV3hgzi7\nsj8u\r\n=+Crc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Community Products API\n\nStreamr client provides functions for working with Community Products. All are async, that is, they return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployCommunity() | Transaction | Deploy a new community product\ncreateSecret(communityAddress, secret[, name]) | | Create a secret for a community product\ncommunityIsReady(address) | | Wait until community is operated\naddMembers(communityAddress, memberAddressList) | | Add members\nkick(communityAddress, memberAddressList) | | Kick members out from community\n```javascript\nconst community = await client.deployCommunity()\ncommunity.address           // already available before deployment\nawait community.deployed()  // waits until contract is deployed\nawait community.isReady()   // waits until community is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinCommunity(communityAddress[, secret]) | JoinRequest | Join a community product\nhasJoined(communityAddress[, memberAddress]) | | Wait until member has been accepted (default: authenticated StreamrClient)\nvalidateProof(communityAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(communityAddress, options) | Receipt | Withdraw funds from community product\nwithdrawFor(memberAddress, communityAddress, options) | Receipt | Pay for withdraw transaction on behalf of a community member\nwithdrawTo(recipientAddress, communityAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a community\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(communityAddress[, memberAddress]) | {earnings, proof, ...} | Get member's community stats\ngetCommunityStats(communityAddress) | {memberCount, totalEarnings, ...} | Get community product's statistics\ngetMembers(communityAddress) | [{address, earnings}, ...] | Get community members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"9f442a014262ad9eb0d87a2e2523a72e3821ca6a","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/* && NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.4.1","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.14.0","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.2.1-beta.1_1587375832863_0.4021750568089437","host":"s3://npm-registry-packages"}},"3.2.1":{"name":"streamr-client","version":"3.2.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@3.2.1","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0b801eabcc0c9af0953092220ad34128a1b62b28","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-3.2.1.tgz","fileCount":100,"integrity":"sha512-pUS8RFMVv7JKnalotL4WobzJc6wZSsYrsfiLpUcOThcZ3hOztExyHAiL++Jjwcwd8uoQDvifnUtVNfLbv38AJQ==","signatures":[{"sig":"MEQCIB3Z0kSfipvW7bIDeDHAFNg1VMM7mI+ir0h7FiVnYiUwAiBhqLVfEy0gDzj4lWRhkICsAlkYLuL0WHxr8Z3u5thc2w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5098516,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenb7tCRA9TVsSAnZWagAAx18QAJfrRgYvtXX3c+UAwWWC\nlRiruPIa+vVVsKzWlOSxhP/qOEykq9v+nC0KzWBtJhx0ydadNHdML2JN3P0a\nWA1MYRCFQCw3rZZ92DNSyFjrrm1VUbi4L5pyQwRf8tyxw6hMNzgMj8G3+hqw\nsFCTgoghP6XFoywSgqeZs8sp31005dKvo9ysWapxJX4pt8lLnjEFAKfJamsV\nwGD0uFiy7DFyIj7SC40UwqXZOYbNhP93RNOmKxvZDL6lYPocmkxBmOyGbXZ3\n/cgCrI6FKSm+/wjB6BTybPhlf65p7vCsGLpHdgwwze3q9kNZPprqIMUD1m6J\nqt/9MshdAYPwqCMUZUiEenroT15+5QEJlYft9j77QlwNKSRZ0O1tv6iiKpTM\nuZohKHhOWvv9IHkKZV6yD4iF8ymJS6XM2uavEZvPE3maAF6ctuaiMrRJ85GV\nBegp4GNTzo5MsVzlMUddpj1yVBEne7aPXlAzaKmv3ocolYVmaqv/56Bene+d\nF46HQkZ03elCQQShmPu2QvsGfCGDTcBzlA0Nw9wAyAopbSyYFyhcU846pgon\nYGrvGCD1/tDuAh8bf+TcdgqFAU6z5iFPfwT42m5A1fFDnkvDHF5YRe5UblIW\noAwKdKh9ydemNMTSEboxyeQ+3Wb66JE+HRMOEvJtacea1jEkdkiV1juExwOr\nK6DV\r\n=2tBj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"a23ea225d2ce19b2e739be008e3857b92a9d300a","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.20.1","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_3.2.1_1587396333063_0.6408704402513195","host":"s3://npm-registry-packages"}},"4.0.0-beta.0":{"name":"streamr-client","version":"4.0.0-beta.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.0.0-beta.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"cb6c23892a414174666cdf5885bb608e927ced80","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.0.0-beta.0.tgz","fileCount":103,"integrity":"sha512-cs42EAJimdIU8ep+nGpxaYVFv0ww90pb+rqgXfB/mT8m7yGC/V+kGIgP9hN4Nw3o3t8jp0GWLxRD+6S3lfDfUQ==","signatures":[{"sig":"MEYCIQCobyffunM9IYU0aS3e44ia1CfZ7pO7RnPsgK6/KkSZDAIhAIxgCyZnayjHxDTvYJiaVhrFiYdVEsSmUuyO16UKyzdV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7898852,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenchcCRA9TVsSAnZWagAA+Q0P+wRRE3MFRT5pPsYwcCtZ\nu5rOAJzy2GHKelCXbXN4a2Ke2CCHt/gZz3fpEsKwCp/h79HRA8CVoCI0VN8s\nJGNd3iSCXHVS5tH5KwL46jxU9SwtgM7pX/RzEp/NxNKanTjRDNpl9WESCgnO\n1ejEgciGCZUCd1p+wbkRJC6AQXx3L4sIiUrD2/RomdPT3lGqxIg3Z5VCILC/\nK2OIoqx+gjmlqxi3vEC/Xd4JYH3/b5XFUhP7UgkTS9ADo3Dao0iH+9uCwqRm\npdWbGquvKGJJWITUeLakDqZhCcZih51ahvcf9Nv12gMcZW5mhi+ZbtA8K8BD\nS6m3BldT74V15setJYCf0veino8UNA1rnYPbUP0EUkrXS9ydv3zLtoXxK7de\ndLz5V/VmSp7zQu0dPydcwCwKnR32NipatXwdrIqu9VTAThQxW0cH914uRP/2\nQ1ALXd7AhYSTnztRjDAvJv/11Lz00ty9VQlndqHitzE9K76ZW3awWPt9F9gr\njbbgcd6peHkaCtqGgpX0CyShRWSkYS9GFqapVdc5+z9KBH47eW6iexwyAPmo\nGB+H7yHxCupiZK/66D7nzfukQNl+AirynF+/BPExBAsJWLfnaobvcRoHijtQ\nnw6JW42f/BGjENURIlO9K/uoGh79NDUThF+nEi2KTl76UvlBpdF6N2p35nEJ\nTkIi\r\n=/BtL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"d58a1eecc023fb9b4e38f24dc5a83b50bc5d464e","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.20.1","dependencies":{"qs":"^6.9.1","ws":"^7.2.1","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.42","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.7.7","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.1","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^24.9.0","uuid":"^3.3.3","sinon":"^8.0.4","eslint":"^6.8.0","core-js":"^3.6.2","express":"^4.17.1","webpack":"^4.41.5","@babel/cli":"^7.7.7","@babel/core":"^7.7.7","webpack-cli":"^3.3.10","babel-loader":"^8.0.6","array-shuffle":"^1.0.1","eslint-loader":"^3.0.3","webpack-merge":"^4.2.2","@babel/preset-env":"^7.7.7","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.0.1","eslint-plugin-import":"^2.19.1","terser-webpack-plugin":"^2.3.1","eslint-config-streamr-nodejs":"^1.1.0","@babel/plugin-transform-classes":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.6","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.7.4","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.7.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.0.0-beta.0_1587398748074_0.0914010754513519","host":"s3://npm-registry-packages"}},"4.0.0-beta.1":{"name":"streamr-client","version":"4.0.0-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.0.0-beta.1","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"38f57152a7bc5d425298f62d809ef4b8483b9be6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.0.0-beta.1.tgz","fileCount":104,"integrity":"sha512-DLchV16Y5vu/MSNsGPqPoc8d37GSOsxybpTpt/+uNfrgh2YzHGGSRRY567DgFQ+UFTfWUr4I7fwLY1Sqq3WqRQ==","signatures":[{"sig":"MEUCIQCtQREVT3p8YONmlQBA+bNAMDVDnQgfekbEMsGWvabcCwIgM2RIF91Yfi2PWCaKO361e2KUVjCbMz0lNP6/TGGiGxk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7949451,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesDknCRA9TVsSAnZWagAACEoP+wZ1q8KKSEuD5+GkqkJg\nMXsbBlNZLrSi2wGjmnmipEU1cC105qUuXuHPQfqFlPskx4j0TzHLbyTX5057\nhHVM7KNViGf3Oy+i4DQs+KU26u2lBcp80mGlELyG/CeBuJ6Lol6JrYLad7lE\nCHbTIQt6FMH1VJce3nAGDGRBDMZtKwIga479kIfeeRgdWSJmEuvNbmkBCbii\nqi2NlzkD1UJMErW/clL8qHC+4gcD25ggLqvuVdBrZ4WDG08taZI0KnX0bCRQ\nfgbjwgJEcP/b1lPkpG+UR36jjOGhcO0Rh23SuWN4r7P67MgdxEZrh8oLzYka\no9UWYmHzebaVjf7s7Q1pC5xndONnvgGX7cZqZaLcZvcpnQjqZCcPRxJO+0PM\n3OXmM/cPDTnkxLoXox6Jf99rbB4C2aQ49Hj1pwBKQWUsI8QlIIlpLt9SKh9n\nZyREqV8I6yZdzBu7pJFbSyXVs7yLbitJ2YNlkPpSx64B6R8JT5X3gG8VIhLA\npfCkyLcePzdasOItVfarho2t175b+ZpJAq2/SHAHifh6dCoybBA49O5jCN3O\nv+mGd5ZB9g4NvEnezr3ZEGdoLMUKF4I3ERdHTEYWs+Rc0//ibrM+3lA+uBr6\nV21LyM0OJL/oDzecu9TVIVrweEOwn7zE9QdBGxCFQ3oUcqGCtkiYlSRsLEXL\nP5us\r\n=iGNY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"60091426c9f0a6538a13792aa7e552d6ac44e8b8","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.20.1","dependencies":{"qs":"^6.9.3","ws":"^7.2.3","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.46","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.9.2","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.4","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","uuid":"^7.0.3","sinon":"^9.0.2","eslint":"^6.8.0","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.42.1","benchmark":"^2.1.4","@babel/cli":"^7.8.4","@babel/core":"^7.9.0","webpack-cli":"^3.3.11","babel-loader":"^8.1.0","array-shuffle":"^1.0.1","eslint-loader":"^4.0.0","webpack-merge":"^4.2.2","@babel/preset-env":"^7.9.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.1.0","eslint-plugin-import":"^2.20.2","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^2.3.5","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.9.5","@babel/plugin-transform-runtime":"^7.9.0","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.8.3","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.9.0"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.0.0-beta.1_1588607271011_0.9160752892881585","host":"s3://npm-registry-packages"}},"4.0.0-beta.2":{"name":"streamr-client","version":"4.0.0-beta.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.0.0-beta.2","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e55543df32cca5b412373afa9a75e0b2777639da","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.0.0-beta.2.tgz","fileCount":104,"integrity":"sha512-PQDAkC9/RQDzYe/igCLoftqMJ81S/mPRINGlmwpGX1qmHHwGFjyXrd3Q/O4HleVWN4wW75q/YdfJBj3JVk9e9A==","signatures":[{"sig":"MEYCIQC0yEN5SwCg65ptUPgHPYLtiYMkQHXxuIecWOkI4phEfAIhAMsN8Y+PsQ9mAZE5j/2zlTu8/jZQs5S602F0pjJwbpIT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8059994,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezAAWCRA9TVsSAnZWagAAUG4QAITOfeHcdnRyJBs41hkx\nZ5hh6RVH/kgMLzUQXVRPLZSlJxzNQsPGzKYZOBxIUKRyiLWCAndUq7n5oADK\npugR5MmIzHt0geo/YKpLcnoD2OOG0HW49UGNPWGf31F83UMA1wagbzwFivoE\nDjrUMYL495Wy4HHBemmuRiu780+0NNsqYW00ZVBlkTNCERs7hcPh6h9lH4EL\nUx6CotNnObHhEbQYvNhLfxspilis28Q4CSSGU4tcCpypPoIxuPaH6vraAz3h\ncGEEcPgrBfXhWtp0ZQ6YhwKdc7VCRpUy5ssyL6hKmtKVodnNCerHxl9u7hpO\nAmOsGHvnxMFzUKU4/4HP2Q6lalZlABvG0eOSIqcl0fTNvhWbPmUOG9bbtx6g\nGCYOCF9fmZj1LpC4AzaMHoCyeYWn5sva4MsEh549EUFbeAG5ITVbx4/0em+5\nW8WTD4VAFHJwP+hvByUZTr+yg0/5htRMhoJXeYgEfdFvLXmbW+UW3NjK386t\nvj51MHnXIC9K3roUETPtMdD4M3tpY7yQd7NBwt9mWodvx+xKZbjCrh445qBG\n19HXpYlRViiEDPaAYxBWpa2hfiPAElHH8REZ/ir8rEzgA80fFU50CqMSOwgg\n7g/MkJO5ACG/qWzSulQ5TcDLYyIam4xVHGT0IXH0e2lO2IfOgCq2HJt/6Lzr\nr7e2\r\n=iaNj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. `operation` is one of 'read', 'write', or 'share'. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"d8e37d92b76f7952a9f523668dcacaaa74599184","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.20.1","dependencies":{"qs":"^6.9.3","ws":"^7.2.3","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.46","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.9.2","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.4","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","uuid":"^7.0.3","sinon":"^9.0.2","eslint":"^6.8.0","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.42.1","benchmark":"^2.1.4","@babel/cli":"^7.8.4","@babel/core":"^7.9.0","webpack-cli":"^3.3.11","babel-loader":"^8.1.0","array-shuffle":"^1.0.1","eslint-loader":"^4.0.0","webpack-merge":"^4.2.2","@babel/preset-env":"^7.9.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.1.0","eslint-plugin-import":"^2.20.2","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^2.3.5","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.9.5","@babel/plugin-transform-runtime":"^7.9.0","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.8.3","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.9.0"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.0.0-beta.2_1590427668463_0.8913924527878112","host":"s3://npm-registry-packages"}},"4.1.0-beta.0":{"name":"streamr-client","version":"4.1.0-beta.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.0-beta.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"106ed26991de5ad53c4b17fbf3572f9c933d0725","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.0-beta.0.tgz","fileCount":105,"integrity":"sha512-KNZF2s5A4QzJpXfTVrXL7fZlJkggRnPHB5ZLslE2bsR9Ef8zDe1swpfFP+9ULT0pPJfRwlIZGLOHN149/0y1RA==","signatures":[{"sig":"MEYCIQDkIpnp4CuVkSNDUlYcduEu7y22yHlsRMc2wiY0iQOGXwIhAKBVBBViTsmhyEupqliUBY+qBpSDSzIspWECI9hHyuof","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10107874,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0L/sCRA9TVsSAnZWagAAqBkP/RYN0+xDRh8L4vN74Ei/\nYJwXB/cN60ft/poFFYa+84b70AsX9TwFbjOBf2AgXsjYHBqKlY8N/4+QMjzW\ntwfS5pgZbnhsIzDM8xvnTNeq4dbZAJEBYwGBFWthitqVTRMYBT85greOCOHs\nzbQxC8oAPENEhxTmTrh0Y622vLY8jEo43cJliWSkvx1wkudpdER9gt3Tc142\nFfBkLom4bidMj0T3ZYtccbowA7hxA6ZKSnQnCuS6MZvxHTRCHFzoDaPgmLwm\neGbNjV688Ij+dNWscW1Uesy4FJwjPB0K6Vo3Bhaxg8iaeg4F5GQ1/uTY1emA\nnQXYqYo9Z0ja5JwFxPNkqrY5MwH3g1rqwA2zWFqIugdY6phE3plX90Meqpos\nttZrDSzI2CIuY0x0YU+enCGlwezy4Jlc+voG38XaxCzLWbDbbF+kpCCgcmZQ\nJ9UETmcEPYNwv++C3pNgMqgwZXgDhpu3gizSWDzF6qEUunkMld388u60mYSV\nSRgPketBcTw3+LxSswcZWJAt9mMCxdQSRc4dzRQzjZJhQDpKEnqH3Rd1esQI\nf4tyEcZjpX642hrnt5oKpD6aQGykYz4z74k7SSK0y6AahBZ/zrhkt0ZbTLcz\nunnL5ZqMCsCwTvpfQvLFAGAlvvn8hRvjoAbt/f1TWzaS1E+JRnXVUjqba+E0\nrZ32\r\n=IXEv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 10"},"gitHead":"de3e873c9a8dd1e67fb4c18612ff6b983ff8135c","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"13.12.0","dependencies":{"qs":"^6.9.3","ws":"^7.2.3","heap":"^0.2.6","once":"^1.4.0","debug":"^4.1.1","ethers":"^4.0.46","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.0","@babel/runtime":"^7.9.2","lodash.uniqueid":"^4.0.1","node-webcrypto-ossl":"^2.0.4","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^4.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","uuid":"^7.0.3","sinon":"^9.0.2","eslint":"^6.8.0","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.42.1","benchmark":"^2.1.4","@babel/cli":"^7.8.4","@babel/core":"^7.9.0","webpack-cli":"^3.3.11","babel-loader":"^8.1.0","array-shuffle":"^1.0.1","eslint-loader":"^4.0.0","webpack-merge":"^4.2.2","@babel/preset-env":"^7.9.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.1.0","eslint-plugin-import":"^2.20.2","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^2.3.5","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.9.5","@babel/plugin-transform-runtime":"^7.9.0","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.8.3","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.9.0"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.0-beta.0_1590738923999_0.5100910993606853","host":"s3://npm-registry-packages"}},"4.1.0-beta.1":{"name":"streamr-client","version":"4.1.0-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.0-beta.1","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5470fa254b1ec1cf1fc821173e0a4a144edaaac1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.0-beta.1.tgz","fileCount":105,"integrity":"sha512-ZoH87uUfiEiuL1crs38/10TBAbzg7ymfBYL6d/I1MfEv1uBgyl5IOkuuSZvMMpbZ8YsEJpMLKacHUNnwCcpehg==","signatures":[{"sig":"MEQCIF9h8hbrkHmzpvC93J2iOVyLfJOVd/ORDhZLKfu4h8MyAiBcF3G8MLTwa6Ea9f/0w5MJLeR+1URw3QYoJ4d0xF9C/Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6329540,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfFrxSCRA9TVsSAnZWagAAjTYP/2aCT0KBqJC51tzU+RGo\nvD7XsMJWvLiimZRN5fczg4dz8PCihx4EWvyaGZDleKV4S1EBNbQFTXk6KqH3\nx+khogsET0EaMniHzKH0rsy1nX1/mXpeDkjM+oUtHzuxe1j9h7aVep151ixK\nJMASSUGZXChLESS3qH7E18dcXA1BogtaVoZrAX/LJaZF1Z4Q1iYfSuh9twse\nl/MoOxFl2u3DcQMg9zW4qenEs42/4y7d78w4Ed7wwGcWpaDBUWlu9fxnmR2f\nQzeP3pX+o0CghaOITrXkxZWGJVvZrOVT/hucnysw6aFEKrMSvkiCJLQ8l9A6\nEiTlHnZZYbVjk9iQoMgVFK0lOBkCazG968dlqbsdwYwj3hyUcMkqacEtYokH\njT0fXa0hZf38xO+pr18HOhl3Vjyob7j2AdgFvHLOYO0ejL4Hv4pd856IeWPq\n/cqs2YOBb+APh+bn2tbdBuAEAN6mL8ZBlNGYONTS2E8YyY3499CheK5uk+br\nIRZz7MQXofD1R0mrihKPvq9QR2Aovj47W/eCtZ/P2hi7I7VsxCLqHJJXtRxM\nf9m4ZVSIlQ06IUnoGfBP663kLXdZm78znVdPINJd9U3pPutzB4YgptcWfoQi\n0f7bMpgpsu13oaFJHMUjrf6GLyAuYRH8jS42BDMTTFQ0cD3CArOThqnk1Nid\nIbnP\r\n=VMRJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"a2c3e4866f37a0e123c87688ac58ddfdbf882ca2","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-browser":"npm run build; node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"kare","email":"kare.nuorteva@me.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.5","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.18.2","dependencies":{"qs":"^6.9.4","ws":"^7.3.0","once":"^1.4.0","uuid":"^8.2.0","debug":"^4.1.1","ethers":"^5.0.3","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.4","@babel/runtime":"^7.10.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^5.0.0-beta.9"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","sinon":"^9.0.2","eslint":"^7.3.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.43.0","benchmark":"^2.1.4","@babel/cli":"^7.10.3","nightwatch":"^1.3.6","@babel/core":"^7.10.3","geckodriver":"^1.19.1","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^83.0.0","eslint-loader":"^4.0.2","webpack-merge":"^4.2.2","@babel/preset-env":"^7.10.3","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.10.3","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.0-beta.1_1595325522133_0.6536352006022692","host":"s3://npm-registry-packages"}},"4.1.0-beta.2":{"name":"streamr-client","version":"4.1.0-beta.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.0-beta.2","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ec53c876fc6c895080cc7f42b8efac16f1920183","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.0-beta.2.tgz","fileCount":101,"integrity":"sha512-+S3EmS3JRDMCTmoQW8xeEyqWI5dWRO1IYiQw5dAQHDgnXgX8PVCKLg+5BkUNXJBYI/JuOQCIUudfAYv53BRb8A==","signatures":[{"sig":"MEUCIQCJxRbYvMxRd216dNkIkM9xBjlbmkjIVA2GxQ5NoxiS0AIgXqAy8YNr2jpNIkaCGFqJEmDVbkPQWFlzlkGhsMxQxzU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3736288,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfKaWGCRA9TVsSAnZWagAA9jAQAIg2O/cJ05JSDXogDS1y\n33jyqxWkoxvzxU0ohXQ3iJDX2wss7UoTx8dbyt6EBNVLGNnLebLRZU5+ZWTd\nrrlcknCKwyumMu+hPT99Pdtums6fdA395RL//QIi0rSV6HIAb4LvkgsYdE4P\neKBl2I3lhLGkaH280trbJuH3AWwRfR9OsZ0jfkt0HZyxk3fOGIaDLiElrytx\nUd5xLKx8dsqBsvokO4PtK2OMhGbhprHItb1+rBXU3C390KtMIiuT2u302nc5\n0t9lHay/u8XNFfZRPEocAWZMrherQGUzvlzAr6kaF9R3PydnoPVF0FH+7YrP\nRUs5zAIlbfKcTrSMQ5e0g3vle7nV4hEqxaYWnAXt7kbbfiXNhNTxEaufpP7h\n24R8R46lKjPjw4Lft1LYYJKbgnBdT9nhOgZt8iYahS7jY0BtIKq+F6Xn878f\nPwnOV3urpve7gapkaVUFwHOoSOcby/zsvMzMs31uD3jMtwnPFxWwHCyxWKos\n3aw5X64+awZW/r9xVH+rbgbKBxsPE+QQ3inXBPgrASpGuf+Bckdks1qm/43X\nZOue2leayvVstYNidUD8/VNOPp+aN4NzQiiFO1vvg6timTKGZ/l5yGWRTDxT\nTy2OjVaqcrPe7vbLWQcV8nGjSNDjT7owP3RSpJ9u+TSdMGJrzgx4r9vsZhC8\nzWGj\r\n=3z6q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"9e4b1dd1d7f569541f3b8828787af3e344c7263e","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","test-unit":"jest test/unit --detectOpenHandles","test-browser":"npm run build; node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.5","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.18.2","dependencies":{"qs":"^6.9.4","ws":"^7.3.0","once":"^1.4.0","uuid":"^8.2.0","debug":"^4.1.1","ethers":"^5.0.3","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.4","@babel/runtime":"^7.10.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^5.0.0-beta.9"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.1.0","sinon":"^9.0.2","eslint":"^7.3.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.43.0","benchmark":"^2.1.4","@babel/cli":"^7.10.3","nightwatch":"^1.3.6","@babel/core":"^7.10.3","geckodriver":"^1.19.1","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^83.0.0","eslint-loader":"^4.0.2","webpack-merge":"^4.2.2","@babel/preset-env":"^7.10.3","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.10.3","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.0-beta.2_1596564868898_0.7343429896760167","host":"s3://npm-registry-packages"}},"4.2.0-alpha.0":{"name":"streamr-client","version":"4.2.0-alpha.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0e88bd2a21002a282bc21aad032c7c11ac868195","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.0.tgz","fileCount":106,"integrity":"sha512-HHcq3YIo/daxHcXhbm9crgxZS0xYM9zPVP4UDMDHQlz5R3lbz5Mzb8KoxzONk54F/WHzGKasJS+kkQR9nZ4r5g==","signatures":[{"sig":"MEUCIQCfUo7kr14BPEbN504LcsciJ7FIjBcQYACgsYiaRGq3uQIgYR8bjapfIHMWNUCpOAWgm0mS91IveD9kLL4GS0LujL4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6647027,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPhtQCRA9TVsSAnZWagAA4nMQAJIDU/TURib7SYIT9dmw\nL0ojZNlY03tpgfSpmrcEiz8ictDIJ9nbEXJtwL85FyCfPA3gt8HRRiLeF9c0\nfAALpbKYXd42dXdx7hNSzIkmho45pOrdRkWiOZbPPkra+CsDT6dbMNx5jkbM\n61H0YiMoN15depz6to+WP1OxuXtiJA3wDl3u6tF9Dzph/d6c2RdKCfioEKGU\n+aDogW9N4yg8xchzIjLP/G83hEUWXvFi+bLNQtkOys7tFJnGseJ5r+lDSbhp\ndSOoV+ckMrRDuBnSM6cAtJuTT3cvArIKrkK8IXZITqqrTZnML5qO2bgBXaOs\nFgzL6UWybVZdNsmbOzVhxGrc3v69mKTykqJO9ThCXLZnNsiOP53fIaaGNO/S\n94IHq5UDpNmJyksD6zp+W0//0t+iDkaPxM8vMI94mx1+HOjxtse/AFMBqNfD\nI28QZHHvQaD4+luPMunZZnZ8khwh9X4uTLhlksuJBqq5MfborKjn3Ifc26ft\nSfAewRQ72VkcCPBOKPMncydyWzZlTgvwH+uVIZG6cNVoO2oPaJpHaU1xlj+5\ncFeIGjLYuJfqycgeb6T6lMBZCDLDmwLu8hyKcCPkkBplx1L5F9glBmGl/9HF\n5pzyNhmRe1PbANqwVs6VaZxe969cJeqjJSzn4SRgjNb86pTr9MfvFrTGIsp1\nRLSB\r\n=jTSt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"0e36a6589c2a0110a6e8c5cfcdc9651fa7b6df98","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --forceExit"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.0","once":"^1.4.0","uuid":"^8.2.0","debug":"^4.1.1","ethers":"^5.0.3","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.4","@babel/runtime":"^7.10.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^5.0.0-beta.9"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","sinon":"^9.0.2","eslint":"^7.3.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.43.0","benchmark":"^2.1.4","@babel/cli":"^7.10.3","nightwatch":"^1.3.6","@babel/core":"^7.10.3","geckodriver":"^1.19.1","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^83.0.0","eslint-loader":"^4.0.2","webpack-merge":"^4.2.2","@babel/preset-env":"^7.10.3","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.10.3","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.0_1597905743474_0.2901812865566158","host":"s3://npm-registry-packages"}},"4.1.0":{"name":"streamr-client","version":"4.1.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.0","maintainers":[{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e32c5837ea1e1646eadb9f377c579170244210b0","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.0.tgz","fileCount":109,"integrity":"sha512-D0mN/+D2xbCbLXjbjF0EZHOu5bKUxKkCQqQhYeDvjtE7BYkL1kjU6jcdnGM9aKXrzPV6zVeoqYm8sPTqq4TE3g==","signatures":[{"sig":"MEUCIQC+Hiuv59bldzb2mdOES2aJjflSAgJYPZhxM4s/Qp2pkQIgbqBQf9RZU3rSI/7F/0DvkUT+KW5plebQzAp/ZBgvgjM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9197335,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUAAwCRA9TVsSAnZWagAAuZAP/3C6iToi/GjB4KDU5hGH\njmmxbg++cel99Y9rt8gdw+keS0SS8RA0rkMDwJCHsLCb0IGZD8tUqzKIgY19\nX6VXWGDEEYduz3LWdfrswCDBh/f8o6kbZOQbPj54h3LeN5BKp32Gr2gPEwfs\nMWY/twRu0m9qj0OU2qKD51mAXSmxwbPBfP8pd7YA5FRUtLFCU7X7VNJTIxuF\nXBCyXlR8Fyfcaj30LyBDXdMtlPAzElvLsJ/L8YjeDZp+qH21Gp9YJdVe7KPm\nax3ImOfsZaCi5xJW3cyFSrYK1E4OVxLQ1fCQj42KOq+uv1Dsn7zqOh6ZPjJG\nFKsZUZ/sYVhO1TDndrT7J+xUaLeOA+ZOxfV0KN7scsRe+RTw/xlt9DrapCXn\nKc1SJCP+nk1ToBs0gBSIkeBaT/i6dbuA3ZsaQVqpOWq5nBkYk2hmIDRguOFR\n/n28Ofe44/s+Dp2Ri77DzBDgCjEk+4OzTmWIMxUALDYAwY4CJ/rbGNahx+7x\ny5J8j5k4ZmUJoSc7/Lfic1dGzwEkyAH7NFEaAfP8Z33CuA4S+/dNIUV74SXz\nKzXVxiISsC+QLwbpa6U+Rzo9e7+LQGFQ4jGORykZh2mCPFFrazwImGxSnBL9\nN4NfPfoVuwDPuYnQflNtCZOiCm1Kymbo7NWTb4dssF+igP2uYchT3NdBwcnG\nqUzq\r\n=81oc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"9c0ef7355d8ecbea3a316434db663eec52b8734d","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration --forceExit"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.7","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.7.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.0","once":"^1.4.0","uuid":"^8.2.0","debug":"^4.1.1","ethers":"^5.0.3","node-fetch":"^2.6.0","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.4","@babel/runtime":"^7.10.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.0","webpack-node-externals":"^1.7.2","streamr-client-protocol":"^5.0.0-beta.9"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.1.0","sinon":"^9.0.2","eslint":"^7.3.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.43.0","benchmark":"^2.1.4","@babel/cli":"^7.10.3","nightwatch":"^1.3.6","@babel/core":"^7.10.3","geckodriver":"^1.19.1","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^83.0.0","eslint-loader":"^4.0.2","webpack-merge":"^4.2.2","@babel/preset-env":"^7.10.3","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.10.3","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.0_1599078447561_0.45711500742246547","host":"s3://npm-registry-packages"}},"4.1.1":{"name":"streamr-client","version":"4.1.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.1","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"d1dffb99d54f8e5f4ad404e74bac15e23570f589","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.1.tgz","fileCount":111,"integrity":"sha512-qZ9XDPRPehz50jh+1J/o7+qyIknaV90xM+yOBOrCUUtyUiTVpAvZC9ogrkGOAhGLrVIyfE3QGBh2DIov3NhIcQ==","signatures":[{"sig":"MEUCIC4hVbbtTk8bVABKkB2hqGJ5TRpKltXwWSaNAJDB3AE8AiEAzpIqq1/fmbaZVjnlDHz1y4ueGLuS2NZHG6/rMr0VHLU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9524917,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfV9UcCRA9TVsSAnZWagAAX0wP/0ep3gq0g8mn0BCrcRme\nuBAH2ztzM1iWcGIKxxDejRxnYIBQH8VobuIaNEAVzdGw6W55qCNXgmWK7TiW\n66ezwKQqMiYsAFgTGlTiuZEUw7C3gePwejxVtqQ6ee7UPA5bcnYbt3ABd6uU\n4er8n6hwKX5UqKDiDPDKyz6bi/n8ok4jlW9x7+JENFyZ4qgL9EEAaesKQL/p\nMeDcBvCHXnI4HbMpgikd6IGlV2I8AwiCZOtvpZ8tpnO8SKgyD1ARUDO43vh1\nNuIwE5Zdlo8IkQKsdDADnWCml7/a1OU+mVjHLbm0vqVETcDAS8YNeL59J9pd\nK5pVYn/PlyzbT/NQy6WMZ671Icd8nGgb2wynrD0ayPNqPdkmmG+uQhSHup3N\naU1SUWyV3XakXABcKLlwf0cgvF5Gg3wGLupFyoltPuoXqaA5JhaRE38abFX3\nZ5FTfTojdepdjq6u2BvMhhYt6fnduPrNFVwOrRtge2l9w2OVtjyEkt1glCaJ\n04G9nRs/1/ciXcU6MGr5npNYC9qa535oU/ypXMa+dexGqa4O2nAc9AHW0Lub\niLjDV9dKnHfwLUQSxPcPo+8aPrQueQAd3aUWpx1yJH4yQ3kZ7NvrlpozgYvN\naccw+1hEPVP3871vdXLXNRLkOtJZSpoMLLoOatO7jDAPAQ40ilXqiIljepI8\nzY0/\r\n=n5Lb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"ec7f8681fd7c4c4ab5983e7caaea65625829bf65","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.7","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.7.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.1_1599591707536_0.691662962629968","host":"s3://npm-registry-packages"}},"4.2.0-alpha.1":{"name":"streamr-client","version":"4.2.0-alpha.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.1","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"dfcb47578b90e5c79e84521f832aeccc65ad328b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.1.tgz","fileCount":110,"integrity":"sha512-h/Xm3nEIiSpQt9Qs408Cutkjh/QZMkMP9aiRmpdJaZjGNREOt66v6Tfj2RqZppHcN9w4rZc/ribz8VzQt4B/jA==","signatures":[{"sig":"MEUCIQDKYSUBx20hXZpbEMb4Egia7BrK1cZEbt0aPBGuL2NvGgIgKBG5p1dSm5yrq9qaxfaVn+ivhbW1m6LLmvz8KrD2kp0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9169695,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfcYxlCRA9TVsSAnZWagAAUIUP/jsmiPoDpTYrnBEmn3lf\nEaT/N/2EgJ3uinV6CKFwWyAiRH3PQ8rV7z/d3XLLHvVIvtQ/Ns9/JPhmbQLW\nmWHXysAjEG2FCgB/Y+E0zgIowg3WNvXgZqW1gRMTRO0PMKWb58TljTrgOi6Z\nYoj1RZMxl95M/rIZMV22ebUZFfN7hQgsin4uIE5YLuXE+KaQd/S8OtQa6rHo\nxCx4pt9Ejl8fPOcFUI7MJe7qhu6LDHd4rSu3mjkXJunLfbnNBLPK8MBwkgBH\nRIx3zIxx0yqxHDqIj4qNv+pQlh5H9H8+Cq+pF1ygAvln2FA+Rookyqo1Q8N7\nKpVXYzsrZyHj8GcMX56Cp9zC2WdghAZxe+rjaIAfoAsDEPsV9bRJD2MHzZyC\nsBMyRp8KXmy2RJsH3BMAcMlWcImlZerFWIvP+hkbMXVfL3yJwpUveEBHVpA9\n0L9+duJuXx27kT1J32tBOQ8SC5GGLmkgNtl1KqcUKfLt1x2qcS6QjRW6dJIL\nnkmGrYYeKwS8+SsgrSaWP1Zr5zfYGPfPTqnTd9hr9bOKWqpcb54s0TKJtf6l\nr4H92L9o/b+aLYjMJPe/eG04j9Hep6xOtWrWFkm4LkFORFcKvML3f1gwvDGM\nN1YgBauVX1J3yADk3rTJ+Xdx+zZBfKwe04rMPsRITK36PrhQ5k1mnoVdc99A\nmzAS\r\n=949/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"1e0b485448d874e87bf7e7a4ac29220e52afc5e1","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"please use mainline versions","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.1_1601277029192_0.06193051417908668","host":"s3://npm-registry-packages"}},"4.2.0-alpha.2":{"name":"streamr-client","version":"4.2.0-alpha.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.2","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"543bb3effa10b747c846e0c2709b100fad9bd7c8","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.2.tgz","fileCount":110,"integrity":"sha512-Jv93j/SqP2TEGb6yZhseVp1zEsdZOZWwa8sM+CbMtQC+edqlUyriIM3XPWJfC5P8SqV/+BsUUckFlqviJs3uLw==","signatures":[{"sig":"MEQCID/oYk2eZI66/vdxWrMNMMikdbPJMJBntNRbPlvOXclkAiBz8W6dRhMugPv8LxLyIQkmeUdwjosHxQ+qJg7cfMZg6A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9169695,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfcaCnCRA9TVsSAnZWagAATDEQAIWoft6qU1x0940RuC5G\nn/cJVzePHTdouoomnREGrEEne8v0L/4ya2Nwg9JgVGUJuCiG7aeLK1xUplHS\no2aKWkN6/f5j+wlCrvL889gyW/J1qnM3raW/6z81jZgW4+hSOdwNnsiRsKBg\nfceNvyfD/DiwU8jDXa3cScvlzI35V69FrbPKlBQ2vrKhuGI7ASYOG9osTDdL\ntfdbQmxUsR/Qu9RHlYT/OF6YtPuqrwY4fP3S28xJIFb21565ejr3bd2A/TF+\n4u5r6i8asr6PejusLjyoZGdrp+Q3rNZjVH0PbQN05/uVCzb8k8flRzpEAAEe\njIhxDVlFx0q9s96MW1YVPLa1+GYSX+G31rj9zHQoeAXX+noi3sqiL+bMnrY9\nvaaUd2eP/R2NwklIChBtpZJQOm2CQow/OTqTLEcErn0zNKW3oIoyfx7/4dVn\nVpAe8zMVFBpMsUDx6LISGw1Ciq8JAcHBCA9mbkqcLhf2g9kJxmtmYF+ja65P\nxZJKs6ICAWwJVpjCoxMGuAzzp/r3S79u3tCWbWnzA/erPSDaS7aca2A8ayBn\nW+4ahz6dHKcgHCQKxF+pDfDB6duOEd4u5/VedhhL9WrXaglpEkt4anCD681w\nl0tCiRtd/f7IfdwtXMDXEZhz5Jr0IxtJ1EQQsRgLitZ2CALR9Xi/sa0C6HVA\nr34e\r\n=BpN6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"3987d59aaf4c7f48cf09dfd2ff658c1a98d78902","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.2_1601282214907_0.2968800438721779","host":"s3://npm-registry-packages"}},"4.2.0-alpha.3":{"name":"streamr-client","version":"4.2.0-alpha.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.3","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c5c54956b9426b212bef8681777c66abbd4e9a00","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.3.tgz","fileCount":110,"integrity":"sha512-wFloqjaUyLg7aNcrVE2Ia+g2SFiakToFp9NUHuUs8QgZZuifWhnZWKjQzCVyGCMswefUZqe/IC+m6nSEcQCEeQ==","signatures":[{"sig":"MEYCIQC3J7/np5Z66/FTUYewr8ublCx/wFfq/VznKqZbJPUT/QIhAKlRX8e0tbuiMYKUrp/Kp43tIRnyCMw2xy0EJxVewqL3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9214947,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffDluCRA9TVsSAnZWagAAGhIP/2F/t7/7xnWIoeeHp1ea\nx63Z6SgVrkds4UZC1Yv5hCHyLkliy5Vvhc5YJP7DHAYM+d+uFfTck6h0NMwj\n6w4r3N01KlPFFc8WU812/hRZ3pvDafpczkeuYBvVUF9dCqH3IV5XRCkKsz8d\nslaoN8ZH3in2/h/azLhikoB+jniumSZR+JqET7h3F7hx6O6qeQXGKK9bP3Px\nAkaAwXRAQsPiww3m+XnePkYl/ZjypkIP0bw8jpF+B9FKwmTWbJzCa9RbCSmK\n0oIbS5tbUo3K2jzP60dtZyhxYGgxg+47HgJ216oARUBNbDT7ssiJr7TylH8t\nPJmRGILLpBLneq4fBmRAMzPDHPBsOv0ueTjlNCVZmIUSdHybY8HpQ2T8GIMc\nhiBlQFyDak1hDDqOEi4lBKtH6awJvUnWbIFbG/GjqzYuK8b8EGqKhy9V822P\n2UL9kUPuQlbFtR8VVPOW8J8AKoGZ98yq6HorO+8pq2M+DrCkgY/qPHw2JJpP\nEg1OiMZKAA5dLkMRgLT9Dg0YOkY0OzO3kursOY/LrA45WBHssjftsRk61muU\nfqNZgYv5o+16wDEbCEXSWHSVKSaKIJYbuqI3VkZ7nPgE/Ov+dbI2ot+GCbkG\nF/l8EQgG1aw2RFkOVNAK8QhVcLedOg/wfJpX/noWW+5mLqNPJfS3mSh/2aps\niNTl\r\n=ODn+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"e762e98a58e28b909c06483a8009c250b3eb4144","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.3_1601976686462_0.4709980903943092","host":"s3://npm-registry-packages"}},"4.2.0-alpha.4":{"name":"streamr-client","version":"4.2.0-alpha.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.4","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mirpo","email":"miroslavpokrovskiy@gmail.com"},{"name":"mthambipillai","email":"melkiorthambipillai@gmail.com"},{"name":"mk_streamr","email":"mikhael.santos@streamr.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5c4a35b26e07f8be25da4f414675b17f9e2cdae6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.4.tgz","fileCount":111,"integrity":"sha512-3qyzcCMAnMLHOn78OnkQZKD2dr7OUe9A1rDmANbFxX9aF2Scq3N3/yEF6xXP8yXBQhVRmsBw2YF7VXnjy2JorA==","signatures":[{"sig":"MEQCIAN5zg7/E0OENvObyqn0O3tH7S3SHP7T+sOtu01kJj8yAiBcp9C/Ja6pbG53AKO/43gvKd887WUsDf47MmYtvbswNw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9217905,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffvcSCRA9TVsSAnZWagAAncwP/jo7+Sk532NW9rvPbxjv\nukxUAMOAbfJF+0vYQ4jM1Nd0r+0NKw++Yh+YpM5NkbzqMaAEIhXNMAyFP9ex\n9J2QPjHa/MqAsW+FtVj/SSx+xrlHerLDxbz0aWN1BtPnRBip53w/unVC0kV6\nDLdKntZum04lJHDlAL8paDmft+2I0dtMExPiGkIS+d//OzmXYZEuDFCZSw+S\nA2zVBnWZJCO4UN6KCEWQ6EDHI9NuBPzpcGIfPMXLfysauTHPmIuhMeQX4Z2x\nX0xZdcF3J/JvALCloJpqDJ/qsRKlqybd/xN0UcRcRgZK4ZPZH1yaBiKvM6YB\nqIyuvqZJeHnrUjaGXjrwV3ITVtL8Zp4QaYJCl5EOWMxUl3q3FP8LlWUDyJZ/\nI6fOe8AdkKQa0A9uROy29aqZFl3VFlRNQE64l8S3+MVQFPpWBLcdYueQpNs0\n1JBO5AYa39uClP3ImAYNmxea1KuYr4BsAkE6KkHYKS0ThVOSRLprMnxi8+Xl\ndPaTx304NcGB6wFmZ3EK3HU0rtgLlsGqD78vInVJQv1LEQT0763yNhn64qcT\n7iyVUJHhohkBBJBUM9+/jaVU5N4udVQGLCdgDjKCVfIEJCWoE8KzlgCIsK+u\n9rXBoTkMibun292mMYnxeG3QjtTM3IfI80nubyW3uS574v/0JBIMrfIWXjSr\noNTo\r\n=Vzxq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"0d406aaf9f4cae61ba96ffa6e59d4c256da7b561","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.4_1602156305536_0.6158501932940341","host":"s3://npm-registry-packages"}},"4.1.2":{"name":"streamr-client","version":"4.1.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.2","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"f146fc7a8dee8381e65f4e711e354565e65ca2e5","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.2.tgz","fileCount":108,"integrity":"sha512-hNo0bcKjwQK4WPKY/JWcOndvI7W3gk+kGqvIQ9URRJADdSyYAPuvdOHYIiuyyyrNfNwkyQ4OMGm5SSAMTBSp6w==","signatures":[{"sig":"MEYCIQDnaOHXYafySfq21PDRCq/YPlGRj4exOs7IcAQyq3792gIhAPQVJWb59vs88dWkjFmSLTh7BapTspOOWPJP9HTzWHnG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11569851,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiaXoCRA9TVsSAnZWagAAaPwP/3GUz4DY/CC+KWWku9ry\nFzRA954An4J3OMu/37OvbvzF7KcwNk14eKU8ka61kdg/Awygws98QE8nOiTn\nyTWfiScgd8A374qbChygSGwEVKZ7poEeUn1FUZZefjxsWrpzNVOvDUykX/VD\nE4vWMpgy58amRNZ4mXunmBqIjwL+PHKTR1QawSvk8Fg9kxxdTzR0uKSFXlg5\nM4fKyHOKAs47X4HNu9AtZtW51j2GRFj+XKEtww0jpOlDPK47PLIIIy/wMMaP\ntpL3xX2OtGWVWltp9ey3HStWf204s3CgROvU6lMZbGs0HL8GWUgWC2nXkix1\nDJLRF+9rbeEhpUK0pwLYy7m/7JqDD8WkwvZuys0fZ8HYj8s7t6pJyvecJMeP\nfWLoutYBlwghzaXR3asmySPZgUw3Ndm49PDt3rJFBTBw7n4LLcySHH9xsE2d\nYhjntGvWLJnPBaBCKF4MTQgzJxb+8qzMx2tndreo1z1gmlo7MxBrreF9mfxa\nuwk24m1ri/TfZFR+wHCN+PmKO8iMbCM18NeFNR+cassm8jj67xLZkqeWi447\n6k3HZOnn/MFt7onmJK4IfgrPe4/2MwvoVbulDtw9LzGxzso1CUQsLm0b56cr\nFAV9F/bM8qQ0SkkQLyia8WFAWjKMmmS2pKYOyEHIPJb6ivjon6o10D8n9jCx\nNqlI\r\n=Pssa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"2b1d6dbcc0e3afbfd39e64a5ec15ffc999c50c2a","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"13.12.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.2_1602856424194_0.2631916541072168","host":"s3://npm-registry-packages"}},"4.2.0-alpha.5":{"name":"streamr-client","version":"4.2.0-alpha.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.5","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3de78c53c92af7a35b4ae048449efc4d81aad648","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.5.tgz","fileCount":113,"integrity":"sha512-UNpiOI8Z9otQKWajw/B8qZpzPRcDCRSFPxcws+fo9+LK6ZhtgT1BFrEx8dKDIJgu7tvWV8sIIp8oz5G/v8rpQg==","signatures":[{"sig":"MEYCIQD9J71fJRUG090vSSH6K5YioEbES/KNdBw9auyC3kLFYgIhAMuEXYOOZPNaBXrL1PTazRs7Tf0MqwxYbjQKy3u7yTCE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9187826,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjVZyCRA9TVsSAnZWagAAobkQAJUN0yHZBrPcRLoOBUtT\nb3ebrwlKsgvXOEpmnG2pSeAdNXKIezQ+HUkjLvwn+s8BEBd/xGpvcrpsb0IX\nY0Rz2ozYRfUmsVoMqnwq4cY4/cX7iC3NLizY8Odd/U1hvaMFWYLPuB2SRqUx\nlh8//7OuLJJePAtTZoKH4WnTbJQ2ygBkLAM2/VKnIX0AOJznLiOXRQjM7ISH\nolrIXHzOtw7IK2nd+RJJOPlr+cs9b23so42F4l4vCMpaboqgJ3aXC6WnPm+G\nBY9+k1plGXKx4ii4C9b8Ky1v6I6cnsUsWWx1K2MZl5J3crmvRQ7GSHGdjI+5\naGq0PD9z4ZlwTkuhSlm9/v3tkx5T1i7OGhXmoxh8lVFpZ2WEsIY3JRCtUIya\ndgF7sD3sCbmZUuBHWOziBH+Oo0DR3fsj2qyCXaQ4ZuN/UtDEABTan1eQ6YOx\nObYDetMeIt168FPyDAE7iraZFAUFnRo6Zk5EmLF7iA4+e5wYJR/5Yvphq34M\nqgNL9Udj9Tg7ci2ZghBZKzeTLuK92lUpSbA6jt4JPRXaoDKk0Ddjvb1yGm5N\nfMz5oi4TeGXsYmMeotmgBbszQFVakTO98zSJn0nu0r+AQ+V+tqPoCAB/ZNh9\nsPu8RpsA8WUB4HQaiRWGV8fuPKmzv7UuyDdgMkkhW4nVzjKKZtGReE5/C00t\n43ow\r\n=998i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"67838589e9846170d27e73f6afd21bba6b3831a5","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.5_1603098226246_0.2903459792902503","host":"s3://npm-registry-packages"}},"4.2.0-alpha.6":{"name":"streamr-client","version":"4.2.0-alpha.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.6","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b48372e24697551f97abf3e435626febe1ded80d","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.6.tgz","fileCount":113,"integrity":"sha512-GEhEVLDu0r1jTy8+VBtqULXyS2lWf9PZp62XLHtvZLXzSDAQStvHfQf4KeSeGCZW81M66thcESmNZgUDB5ndHw==","signatures":[{"sig":"MEYCIQCm2WdsgDE7q9BpZrG5uH8EEKw5qCUm3mLUj2f27QMNmAIhAIFD5tZMjqYj6MsDMMZrvndcXt51jeu5V2Rwr6ySkHA1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8352353,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflsTjCRA9TVsSAnZWagAA/ygQAKHG+K3ELJSgBwcE1nSQ\nLtqvf/zNqRPo0GJWcoYswWjHTkHWGIS4ev7GO6y7auQTgQ2TyodpdZjUbbIb\nISBNDDjJBW8TPxeWwGb5euzHpinex5tEWPymeSwSkbLzl3Nu39LnKgNbRQfP\nWXey9rnWooTVGwKoSv5ySNacSKth5KDHkL+P9jMMYY/co2gkcl9NM88LkyL+\nOXvQzSPmyqh2b/mRzHEVauG9oOOysEjMxAA9Ql7Bxcf924ZNZOvUXSGhT0bq\nYNlVYnPgevGbyBpYbereq8pVLF7+/RRoEXeqWiS1Ygv5RpdImNTm4hGHWT4n\nnnhJ61/0Tzeyfumwz9dMIEwJTEZYxYTelDhQ5gCIhS9rYjtCUFCtgs2ab42z\nrVJ2rasesFYJcJOxoVrvQLrAT/uVGSDnvYugNscPJgw7lyWZqrQeTnJ+youH\nDZdXHvb0ke8pslPNhnFCIEyx1ST0/0cMz7XYLI8RvNOlH4nb42klYzQnHiGV\nXT/eC+B/iqzM5if43Mlp8vgOhEEEDVXJD2g+v8/WLRnDiaFT3YbzEcrR3yzT\n9Orw6m2bsqbnah9gT5fpdh4Uw87hxzI6t10Q1jDI03imgH7eXGyFnOm7+08x\nb18h7pPP03Nt95jZ/RcS5eMAp3fwOwBSbnbJgnKJaJDF4DdR46pjlluM2SNd\n/Ngw\r\n=3xy+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"dbaca24c47efa643ecf6fe4a1e0c05a7e6e52782","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/providers":"5.0.7","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","ethers":"5.0.12","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.6_1603716323281_0.09439032808751735","host":"s3://npm-registry-packages"}},"4.1.3":{"name":"streamr-client","version":"4.1.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.3","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"180d3258ba4f02ca902d79d44f2086e9767e73c9","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.3.tgz","fileCount":106,"integrity":"sha512-7+SjZzAN9o0i7vuXTUDf2i7btNW467FoHs082ZTnmYeWaXgF+WybRmMzyu0BBWJpYL4X4UUh32k9nmjEo2RMFA==","signatures":[{"sig":"MEUCIQDPICfsyB4DmgOfchWKzWrBAsdnDirtL2urq090fCyaxwIgJGGfQHmGJbnQSbwGL6XH03TbIRZu+62CuTwL4RErl38=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6741581,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmZN9CRA9TVsSAnZWagAAGKEQAI3PLcOI3EfDMpCzd/aI\nNuC7TELFrfv+VxxJslOGNCV1lBuJggzpll91xTb4NLm08PeXHpxivxhX1nz7\ntsy9us8Rggrb94BpnapqcWPv46t0IOOkZQF9vde8i566yy9I9CCB9/prFGRc\n0IXbb8L+wNrTZ7Djgng9aHPBspA6hfmSZdUeLLrIC8tI3JYV/ZTLZw3H5G0v\n/b8FVmeURfvqfxyOd7hPPRl1WudxTOPj4iquKt7CnHxe0hH0Lv+q/zx2+o7K\nRgO2+z9ni6zb+xjhRoQM0AnHTBKlJVcLdCdJaAcKIyefemujS7UcuBYAjcL2\ns0XI0RsUXFrZ8Bdc2gcs8zwCtt0679gnoN4xw+hdFqWrQVV6DViCEmn9RW42\nA4Vnpv0aDNliT/rADK9NBR/7LKgDfVVBfmuvQDg0wLqe8aO5x3OH9gcxFa9v\nbpRZXP/Aztl6qPwjkE1pZEQafrI+AYdvC5j0ZlMYDYFRiiKiMkQH8zU2ll1a\nZk8q9iSB/AKBFxBR69PiXFxF11QM2fpgZjvQkbYnOqHiO9LqYsCzDZTn0iEW\ny+OQvN330oe6g/OegpRFoBzICKUp7HmJP3erPWw0ueM85tD1BEuXAEbjIXIZ\njR0tsdm7Bokeng2BNFFijBhhn6jzHeVf/RHRH81jzK64EGQV6ygaGfifNWVm\nVAb/\r\n=TH8A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"47ce7f730cdf07ee039c089747f6708ec9b8a931","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.3_1603900284989_0.039659425085054156","host":"s3://npm-registry-packages"}},"4.2.0-alpha.7":{"name":"streamr-client","version":"4.2.0-alpha.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.7","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ad8b5d10d147229abd6f6be1b0083dbdcc41fa00","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.7.tgz","fileCount":115,"integrity":"sha512-Ium8SlxgGmPpCxG6n8vC/wNYAzvTG6/KxJzD8KNoSYkNBdVU+oz81jER+zUOqgrntGKUkPfeAry+p44I3oRRiA==","signatures":[{"sig":"MEQCIHHB7dp+2ZCYmJgS3IgcWYeCvW+8JNKp9Gx3aG1OqVsAAiBoaQmqIyuuxUZxMYfiQVMmkzR+JA24AC/F6a4fn0DLkw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8392914,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoUBlCRA9TVsSAnZWagAAlxwP/An+42/19+v92H8F6KoK\nVnxxRXsmCBSIPCgHXQl11GjapslrrT/g6onZHe7MKJ49QNGMsbP9TqJaTVzw\nQ80SNJyQmivJNiFfomHYNHsxE1d9FWTk5hlh75BSvNALRXg+17IZNhG7wcoi\na91uld4b6Wj1dZ06Ij+Q3j+njx6DEPzf2cyE1NzKN3xaNXrsmfQETa6dlZzd\nrMURO5yj7lwIBnNbVRs0dv95eAygHdb4IJ5V4VRRERw66eQ+jXyRWB2pUiKf\n54+gpsnacJuxjdfm1Q6cxg0FmZXNgCLOTo1szmBYnSyyNXEihEiGFNhjlMD/\nXnOrLcYoDovicb4aPgFXgMpdFjnEixqEUd8N6dZ4WvEKmUzw1uUagYVdGoHj\nJJf1/JPN5rg3ns3nBPYJhYRMFBWFwVIYVyeYqN63dT4rU2M9hmCDXRM5Zd7A\ntB4V5U2/LGHaDR/ECA8EnE2MdNoUNvR2cqTCali35vAyhq8P0uW3V3ysUz5S\nbmmLQhEoqtsYkh0S2+cw3D7Qz2UVsy0qqkDt3wlUBHizz/hdsYqQseuWidF4\n4EkDp4iAxGIs877UEwBbF1AaiF4SzMgGrWObNvxoQWzGOGq0Gta1BQkG/Bob\nuMh7PYLuMGJzl2zjCOAA4AP6kEzVXxMawoM+oiEpzd5Z6+0VE+SJdPVi1ETt\noDyg\r\n=ytoM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://streamr.network/resources/logos/Streamr_mark_positive.svg\" width=\"60\" />\n  </a>\n</p>\n<h1 align=\"center\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n- [Streamr JavaScript Client](#streamr-javascript-client)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a StreamrClient instance](#creating-a-streamrclient-instance)\n    - [Subscribing to real-time events in a stream](#subscribing-to-real-time-events-in-a-stream)\n    - [Resending historical data](#resending-historical-data)\n    - [Programmatically creating a Stream](#programmatically-creating-a-stream)\n    - [Publishing data points to a Stream](#publishing-data-points-to-a-stream)\n  - [Client options](#client-options)\n  - [Authentication options](#authentication-options)\n  - [Message handler callback](#message-handler-callback)\n  - [StreamrClient object](#streamrclient-object)\n    - [Connecting](#connecting)\n    - [Managing subscriptions](#managing-subscriptions)\n    - [Stream API](#stream-api)\n    - [Listening to state changes of the client](#listening-to-state-changes-of-the-client)\n  - [Stream object](#stream-object)\n  - [Subscription options](#subscription-options)\n  - [Data Unions](#data-unions)\n    - [Admin functions](#admin-functions)\n    - [Member functions](#member-functions)\n    - [Query functions](#query-functions)\n  - [Utility functions](#utility-functions)\n  - [Binding to events](#binding-to-events)\n  - [Events on the StreamrClient instance](#events-on-the-streamrclient-instance)\n  - [Events on the Subscription object](#events-on-the-subscription-object)\n  - [Partitioning](#partitioning)\n  - [Logging](#logging)\n  - [NPM Publishing](#npm-publishing)\n    - [Publishing `latest`:](#publishing-latest)\n    - [Publishing `beta`:](#publishing-beta)\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the [API docs](https://api-explorer.streamr.com).\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"0c455842dcc391199077948153486e08f28e2800","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","ethers":"5.0.12","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.7_1604403300498_0.8371032814483192","host":"s3://npm-registry-packages"}},"4.2.0-alpha.8":{"name":"streamr-client","version":"4.2.0-alpha.8","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.8","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1f27027c73af0da4bbdfb5e2469715c83502655f","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.8.tgz","fileCount":115,"integrity":"sha512-eETiNgPfhcbLdNTVEO0ZpZf3HOiq2b6w+irScAuEoHEWNCG7/FgZU2HJzzGuHBJYvwjJ+Il0GlBmXuSekFSAZg==","signatures":[{"sig":"MEUCIBUtOPz+gZWU8k5CdOFXz3XUZrf1RFO9Gd+cG3ECIPblAiEA/qkYJk8mfO4kKDSS4FEKGtCUV/3eSM96hyYrheB+0j4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10569501,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfopjcCRA9TVsSAnZWagAAx6MP/2byD0eVPflXb2wJEPPN\ns8aZHjsZKfNmi6mhiIzT8swlxGxQUc6MLGlNcGAz4b+sbRMaBEwnPgMVbvuo\nWU30Z7Js6sZv6bWq1VNUODSeIDvy30mRI3ZBYu+KjEEWguW1xu1wmYn/rZ6x\nlQI4TfDjlqszJe/GA2a75XIhx69NtL55edj3SwlN77zbY61ZrvlwRdyJcKOz\niZpA/iQgbjHOwYzztoQbm4gfTQ5/AeOB+B54yxO8ualgw1QRlJKJVXliKWxk\nl47ROiMMbLxPI88VGueZI3am1lifT3p9b2IWi02wUyY2TVTcMAoul+gBY5bb\nTA2lKiq3WOq/5WuCBlsZgjgZY1H1Tc10hddMxF6Jk+dZVk7HeQY2U/KOjtix\nDAcxq2Det4F07T8TJ8Dx1txoV0BEl4fqPJRzgnbL6gZOzsZtUI2rMwk5f8k5\nmhLK90oBBiPFDl0LEYOZ3jdIJPujOwflnx2dMSa8TBWXxDVDYEK612zSGHCV\np5Ew3ywc8qYNpXKfsMwx16PrYkqBIJcErrA7NjMuX4uZOihzAEQS61wETV16\nCVMMYVMGwu+khKtWjeXgIihkCoRbFNfzCZBASYg3U7mdqZdhfIlhPnmdGpQC\nuQ7lA880yU8VTdCiMqzcrShLXW5hg4VZDcfBc36XVMPdLMzEoy5ng6sDPi35\n5zCB\r\n=xvnF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://streamr.network/resources/logos/Streamr_mark_positive.svg\" width=\"60\" />\n  </a>\n</p>\n<h1 align=\"center\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n- [Streamr JavaScript Client](#streamr-javascript-client)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a StreamrClient instance](#creating-a-streamrclient-instance)\n    - [Subscribing to real-time events in a stream](#subscribing-to-real-time-events-in-a-stream)\n    - [Resending historical data](#resending-historical-data)\n    - [Programmatically creating a Stream](#programmatically-creating-a-stream)\n    - [Publishing data points to a Stream](#publishing-data-points-to-a-stream)\n  - [Client options](#client-options)\n  - [Authentication options](#authentication-options)\n  - [Message handler callback](#message-handler-callback)\n  - [StreamrClient object](#streamrclient-object)\n    - [Connecting](#connecting)\n    - [Managing subscriptions](#managing-subscriptions)\n    - [Stream API](#stream-api)\n    - [Listening to state changes of the client](#listening-to-state-changes-of-the-client)\n  - [Stream object](#stream-object)\n  - [Subscription options](#subscription-options)\n  - [Data Unions](#data-unions)\n    - [Admin functions](#admin-functions)\n    - [Member functions](#member-functions)\n    - [Query functions](#query-functions)\n  - [Utility functions](#utility-functions)\n  - [Binding to events](#binding-to-events)\n  - [Events on the StreamrClient instance](#events-on-the-streamrclient-instance)\n  - [Events on the Subscription object](#events-on-the-subscription-object)\n  - [Partitioning](#partitioning)\n  - [Logging](#logging)\n  - [NPM Publishing](#npm-publishing)\n    - [Publishing `latest`:](#publishing-latest)\n    - [Publishing `beta`:](#publishing-beta)\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the [API docs](https://api-explorer.streamr.com).\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"c16049f64770a166ac76ffab34337b2b04fde8ee","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.8_1604491483867_0.8860315574237358","host":"s3://npm-registry-packages"}},"4.2.0-alpha.9":{"name":"streamr-client","version":"4.2.0-alpha.9","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.9","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c3d75edcc5ba1d402e33bdec51ac7b582705c941","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.9.tgz","fileCount":115,"integrity":"sha512-YC09G45kF/W9hcvg+Dmk9dL83SLVnLhjc5CQCwvp5cYGpeoBgtw8bQgO23asw5x0nufqzHw4p18GpqVnD5eC/A==","signatures":[{"sig":"MEUCIF7AFSaZpj9bVIGw3D96MtYkt75dP/RNmHZY2atE3kL1AiEAqedJ5oty+a9aEdd6a8MNxQyZq/HcqgQFNkdEJEZ5aHE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10577603,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfrSFuCRA9TVsSAnZWagAAXdYP/1KpHtj4jlE7s0xFHP2e\nnIWidmmbxu9kIq8iO3OrIsTD3lf4aKjl2wDx7ArfyDjXOOdWxu6QWVuGish1\nrPDK0Kg2WVLQqnrUstjAfmZ/otpKKoxrJSqm9yPYnapRlni9gg03lMqZNujo\nhwDVMauJHCw2ZbwCiFG8U64AG8x2Qkt4BMQcm9+uaKU8ffW9uowMM2f7U1Iz\nugrOs8wm+7R/hHQqkJeFtV0QodMinBvXhP5DVhu/vXzwAHR9v3bqFStiCzAh\njQoSzrexUYAfMXATo6RwcFTpoiNG00j6CmaxqMQqY4+UylVdPTHtf/U71mJA\nrAJyJiUaXbJMDUo6HkS7Ra4Xq5T4UU3VbKj2VYqzT4FYikyBRI4RT+WPe9vE\n8Nq75CLRjI8F1+nMoDG9KtSg+aisn1xSCbeEqJua/Gf4MyarS7gM/FekD26u\nixkxGwfQHg/VbwE1UOsrRCFNJVQubOf1UAENcOXemWhEgVglIfOsct+yMAle\ndmwTlOgBHxub7lVNltu9mye6Bm911kryIVtSciOQ5/Wf3i1CfUk22EFxcw//\nwPjunoZo+6QJNv58UPwXIDg+c6Kaa5FUHWF5B1wIdQ5IoRehXMyfRflfSmVi\nTtgqqQU8hNkTs5RSsK7AabuHvdVzaDjU/q+Eczo04ssYU3juM+HxDqXYXHRr\n+MHP\r\n=9zcB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://streamr.network/resources/logos/Streamr_mark_positive.svg\" width=\"60\" />\n  </a>\n</p>\n<h1 align=\"center\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n- [Streamr JavaScript Client](#streamr-javascript-client)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a StreamrClient instance](#creating-a-streamrclient-instance)\n    - [Subscribing to real-time events in a stream](#subscribing-to-real-time-events-in-a-stream)\n    - [Resending historical data](#resending-historical-data)\n    - [Programmatically creating a Stream](#programmatically-creating-a-stream)\n    - [Publishing data points to a Stream](#publishing-data-points-to-a-stream)\n  - [Client options](#client-options)\n  - [Authentication options](#authentication-options)\n  - [Message handler callback](#message-handler-callback)\n  - [StreamrClient object](#streamrclient-object)\n    - [Connecting](#connecting)\n    - [Managing subscriptions](#managing-subscriptions)\n    - [Stream API](#stream-api)\n    - [Listening to state changes of the client](#listening-to-state-changes-of-the-client)\n  - [Stream object](#stream-object)\n  - [Subscription options](#subscription-options)\n  - [Data Unions](#data-unions)\n    - [Admin functions](#admin-functions)\n    - [Member functions](#member-functions)\n    - [Query functions](#query-functions)\n  - [Utility functions](#utility-functions)\n  - [Binding to events](#binding-to-events)\n  - [Events on the StreamrClient instance](#events-on-the-streamrclient-instance)\n  - [Events on the Subscription object](#events-on-the-subscription-object)\n  - [Partitioning](#partitioning)\n  - [Logging](#logging)\n  - [NPM Publishing](#npm-publishing)\n    - [Publishing `latest`:](#publishing-latest)\n    - [Publishing `beta`:](#publishing-beta)\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the [API docs](https://api-explorer.streamr.com).\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"e7c4548650a985776aebd8dfa27041e110693fd0","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.9_1605181805682_0.19517203189613364","host":"s3://npm-registry-packages"}},"4.2.0-alpha.10":{"name":"streamr-client","version":"4.2.0-alpha.10","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.10","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"7f7c406cacc1a33237776160e834882fe03a3038","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.10.tgz","fileCount":115,"integrity":"sha512-qRlg8zdGqEl6YEySFooknupFOPAwkIWx0JHPJHnK+K9p/gD6eEz/ud1nH7opMEU/9Z9ydIdnEBFEtfugflD7WQ==","signatures":[{"sig":"MEUCIEDVcip8eJIFIphRHA+92pkeVindv2vdGrYDK6inUXCsAiEA33FlWk4rWwcoatU3gY4xRDP21L31qQLeolRo0TNT3CI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10574084,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfrnu9CRA9TVsSAnZWagAAhWYP/2SnumbK8VZNiuRgnHjX\nS2Yh9xV4ftF8SqbCAYS1Ay0Dv632uxEK+b9fmrz4xOYn3bIAJEr6dGpnVBu7\nAdvFttB81fPN9LMQTvh8cD6gyKPnAZf3QUn9/3DqrWpwrn1EOG0aSYCv/mA6\nRRUDAurSckG4qSJmT/KvswTLc355y41wjRi2XwvLMx9lnaS518CzZRX1rbdq\ns4EGqhXiD9lkVI+qbRyFBHKJHBEPc7T+j0MtMDLsTOmkN4ZjlIOEaIHb2w10\ndp3YNle2aIUQy7ZdQJTVlZXiXowA28Y/6CahA5ro3BT9w3he0GD2zyTrPxsE\nM2eFdYwTDbVMBB/1Cv44CoHooOK5I2BBVlWmduC/DTu5JPtbgKwY0pSs745n\nYcbHTPvUA84T3FkB3CmBvnQkZcz/d2qedBQpQgsGy34vqSZxY2Nmm9FwCgml\nKjdVTZrfidaT+f7vByek70f4oLdbIMsq0y9X0Id0vY+R3Y8kVxXmBirDirf5\nXmYmKQGSWcYqom4hBt+LOpQSuKmXx+bvP2w4Km1qr+nIy6jnQwHyTC5/D6Tt\nAtIbrBPdtsbDd+KK2TPtaMMSTKIrt6EZcXD+XLb1RvZeZaW0VW9z9A5OgsIw\nM+XZHlACzz4YQmMiHi1yVqpadatZA+dYY0VRe1qQHJzY8E1NFd6KqtB7G+Ts\n5yaL\r\n=C8oS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://streamr.network/resources/logos/Streamr_mark_positive.svg\" width=\"60\" />\n  </a>\n</p>\n<h1 align=\"center\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n- [Streamr JavaScript Client](#streamr-javascript-client)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a StreamrClient instance](#creating-a-streamrclient-instance)\n    - [Subscribing to real-time events in a stream](#subscribing-to-real-time-events-in-a-stream)\n    - [Resending historical data](#resending-historical-data)\n    - [Programmatically creating a Stream](#programmatically-creating-a-stream)\n    - [Publishing data points to a Stream](#publishing-data-points-to-a-stream)\n  - [Client options](#client-options)\n  - [Authentication options](#authentication-options)\n  - [Message handler callback](#message-handler-callback)\n  - [StreamrClient object](#streamrclient-object)\n    - [Connecting](#connecting)\n    - [Managing subscriptions](#managing-subscriptions)\n    - [Stream API](#stream-api)\n    - [Listening to state changes of the client](#listening-to-state-changes-of-the-client)\n  - [Stream object](#stream-object)\n  - [Subscription options](#subscription-options)\n  - [Data Unions](#data-unions)\n    - [Admin functions](#admin-functions)\n    - [Member functions](#member-functions)\n    - [Query functions](#query-functions)\n  - [Utility functions](#utility-functions)\n  - [Binding to events](#binding-to-events)\n  - [Events on the StreamrClient instance](#events-on-the-streamrclient-instance)\n  - [Events on the Subscription object](#events-on-the-subscription-object)\n  - [Partitioning](#partitioning)\n  - [Logging](#logging)\n  - [NPM Publishing](#npm-publishing)\n    - [Publishing `latest`:](#publishing-latest)\n    - [Publishing `beta`:](#publishing-beta)\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the [API docs](https://api-explorer.streamr.com).\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"83de5918bc2659f1b1c979d9ad58191627861f80","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.10_1605270460891_0.7849397434288905","host":"s3://npm-registry-packages"}},"4.2.0-alpha.11":{"name":"streamr-client","version":"4.2.0-alpha.11","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.11","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"04050806069bd0e4f18ecd3b0459bec0e8b22b1d","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.11.tgz","fileCount":115,"integrity":"sha512-Ye4M+wyhmI208FYaD/iO8Bu48ZkFFNCvnkCYxttvKHqFtn0txiGTXfomY3LDuh22Y2k/2PR2S1O7SGoQHbSXzQ==","signatures":[{"sig":"MEQCID9mM5QxRLSb2k5t+Zs/ob2XFoyPAL5EGcvr50K+ubLbAiABzMx8K8HekTYwD27C16x6RWg/godVCGBmDTwXH+5N/w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10574894,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftSE5CRA9TVsSAnZWagAAvqAP/3nxPvnkyieZVBTe2aFY\nGQ2/E/3L8Sfy/VSEhN8o8OwXJ3ATGsN5w86i0F8Kd/IHlwA2ZpBfl572WC0S\nuP6TIKiso4VG2BZvSoam49GCAo/SQ8Isb0VexSAEmVxcIj2l95EClM3T0Vr5\nVt4Bcd1OlkR/CjNgfXt/sET1S4il6FvcKcUS+A8IbfQ9Q6sa/gOLaoVbG0WJ\nSVisM4UyZTE+DryWDGB7XR/soET57XN76ENICM6n1M7AoUJUta558nea7Pkg\ntANAlsXLbTSIE6oJLrBsJCdBn2OsvMBa4s7d+mz0/0rNiCBh+36eZ8gdOaQJ\nAlV7Mvz6EI3c2CP+I6XSXNJx9x/tO/O/MGg+Mo/chXtCrt/4MW96RiVfL5yZ\n5t274x+amytr4tsGUnblSU6Kl/OQ+F2Qd9JAvvtEhEf5PkpTpRoNBmARG9bV\nHLH8K4RZXkNPpLx00UaD3iDORGQMwtYKQAwVFfTRTWkLgLlkavzxEEvoOyAT\nQ87Jbrju65hOaIhwZ9pVbH1cOqtiyp7SQl76HberDDw9QilGzQZPHnAo/sC5\nYJRI8vnBjelXm+FOrj7sUVxVTFKg7IVgV881NNcXosx+c2WB5Etf9EoCjMed\nr56r7o0xJ6JrHOYQ0P0gSQa6bYeNrSu1BOs1kf4XpBLL0EkW1g/IJ8+m/apP\nC6we\r\n=tPdz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://streamr.network/resources/logos/Streamr_mark_positive.svg\" width=\"60\" />\n  </a>\n</p>\n<h1 align=\"center\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n- [Streamr JavaScript Client](#streamr-javascript-client)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a StreamrClient instance](#creating-a-streamrclient-instance)\n    - [Subscribing to real-time events in a stream](#subscribing-to-real-time-events-in-a-stream)\n    - [Resending historical data](#resending-historical-data)\n    - [Programmatically creating a Stream](#programmatically-creating-a-stream)\n    - [Publishing data points to a Stream](#publishing-data-points-to-a-stream)\n  - [Client options](#client-options)\n  - [Authentication options](#authentication-options)\n  - [Message handler callback](#message-handler-callback)\n  - [StreamrClient object](#streamrclient-object)\n    - [Connecting](#connecting)\n    - [Managing subscriptions](#managing-subscriptions)\n    - [Stream API](#stream-api)\n    - [Listening to state changes of the client](#listening-to-state-changes-of-the-client)\n  - [Stream object](#stream-object)\n  - [Subscription options](#subscription-options)\n  - [Data Unions](#data-unions)\n    - [Admin functions](#admin-functions)\n    - [Member functions](#member-functions)\n    - [Query functions](#query-functions)\n  - [Utility functions](#utility-functions)\n  - [Binding to events](#binding-to-events)\n  - [Events on the StreamrClient instance](#events-on-the-streamrclient-instance)\n  - [Events on the Subscription object](#events-on-the-subscription-object)\n  - [Partitioning](#partitioning)\n  - [Logging](#logging)\n  - [NPM Publishing](#npm-publishing)\n    - [Publishing `latest`:](#publishing-latest)\n    - [Publishing `beta`:](#publishing-beta)\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the [API docs](https://api-explorer.streamr.com).\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {activeMemberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"e4bf64c6cfd840dbb9c3920d85d373e764836ba2","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.11_1605706041307_0.7489109498263129","host":"s3://npm-registry-packages"}},"5.0.0-alpha.1":{"name":"streamr-client","version":"5.0.0-alpha.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.1","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"7e94355743f6dd0017c8f96e1449f0838c0cd807","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.1.tgz","fileCount":100,"integrity":"sha512-zUzgW2jnl5+Zn7q6oOvCF4syhRzzpzvGRDs+bcTmXXuApGfL3LRXD6WicLCn8Dr2LKeIk5CV7Y8dEC7C0TlI5w==","signatures":[{"sig":"MEUCIQCDZsc5sDZL2U0g7offVIEeRuza1KBxGve8oe/4yjHE3gIgRn9mw6oKvJpojQrMMvUX8l79GU3RVFD1FRfNDuLEKGw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9696921,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuD8fCRA9TVsSAnZWagAA770P/RB63ErjecyJROnSj527\n8+3Qzs4x4Bn5HG06eLQ3/7su0So0V/nnImzvAybA43QQm/CpG/HzXYxZ/xRV\nYq0Pmj0Pu9AkhI7zRW4r/a7NQQSFjvSYREJ8M0QmHhCSL8zIv/dr4bXM41jt\nAD0jS/+gsrbYw1evj/AI4l/ie/9R5Rj5CNJhxgL1IYzPlIiY/bo/v4p/KY6j\nAh7sqQLcndW009uATmZH8FXce10IwY5E7vxliTPT6BdPLRN9TYX8k/gYwXPF\n/3wUE4ZSO1wLErpjqLdcSUE7RRBYCCviO+RwbCVw9OMtoNrZh0T9bR9tvU9s\n/VlHfyJYDDFbPygmmcynpFuRX7hQOIaD7ikmmkoErJQny67Wbga/ExER+mhd\nysEnInU4K6SLjxPEqpxEwTq0cfCN+Et6QDkL6SX8CyvmdcbMPn1Q9LaY4H7d\n21/M9Tzvmx6Bp+7g6lUINfDEq5kEN/XHyu9xFiumYaB6ZGuViLrj5nyn/XMr\nseJtndRo1Sb2WrtdUY7TqgO/pmECP5/n4YN6wljhVNZTJPmvex5QE56eKGhX\n3NHp7qZ1DKIf1X4NuZbwe+j20otJISJ4mvMMVQ4IDHxlF5pFVBOKyDUg6TY4\nuhHfcYSv0/vy8iNq/gsyhynJQqxwS92q5qdVZEZX7LsMQasCJ1UmU+U1JtXo\ntRpe\r\n=bXvD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Streamr JavaScript Client\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in Streams, produce new data to Streams, and create new Streams.\n\nThis library is work-in-progress and doesn't provide wrapper functions for all the endpoints in the Streamr API. Currently it covers producing and subscribing to data as well as manipulating Stream objects.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n### Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n### Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    // See below for more options\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data \n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the Stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n\n#### Programmatically creating a Stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome Stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the Stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a Stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the Stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the Stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n### Client options\n\nOption | Default value | Description\n------ | ------------- | -----------\nurl | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.\nrestUrl | https://streamr.network/api/v1 | Base URL of the Streamr REST API.\nauth | {} | Object that can contain different information to authenticate. More details below.\npublishWithSignature | 'auto' | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.\nverifySignatures | 'auto' | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data.\nautoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.\nautoDisconnect | true  | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.\norderMessages | true | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.\nmaxPublishQueueSize | 10000 | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.\npublisherGroupKeys | {} | Object defining the group key as a hex string used to encrypt for each stream id.\npublisherStoreKeyHistory | true | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.\nsubscriberGroupKeys | {} | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.\nkeyExchange | {} | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.\n\n### Authentication options\n\nAuthenticating with an API key (you can manage your API keys in the [Streamr web app](https://streamr.network)):\n```javascript\nnew StreamrClient({\n    auth: {\n        apiKey: 'your-api-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n(Authenticating with an username and password, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\nArgument | Description\n-------- | -----------\npayload  | A JS object containing the message payload itself\nstreamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc.\n\n### StreamrClient object\n\n#### Connecting\n\nName | Description\n---- | -----------\nconnect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting.\ndisconnect() | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting.\npause() | Disconnects from the server without clearing subscriptions.\nensureConnected() | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.\nensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection.\n\n#### Managing subscriptions\n\nName | Description\n---- | -----------\nsubscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.\nunsubscribe(Subscription) | Unsubscribes the given `Subscription`.\nunsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.\ngetSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\ngetStream(streamId) | Fetches a Stream object from the API.\nlistStreams(query) | Fetches an array of Stream objects from the API. For the query params, consult the API docs.\ngetStreamByName(name) | Fetches a Stream which exactly matches the given name.\ncreateStream(properties) | Creates a Stream with the given properties. For more information on the Stream properties, consult the API docs.\ngetOrCreateStream(properties) | Gets a Stream with the id or name given in `properties`, or creates it if one is not found.\npublish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given Stream.\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\nName | Description\n---- | -----------\nupdate() | Updates the properties of this Stream object by sending them to the API.\ndelete() | Deletes this Stream.\ngetPermissions() | Returns the list of permissions for this Stream.\nhasPermission(operation, user) | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions.\ngrantPermission(operation, user) | Grants the permission to do `operation` to `user`, which are defined as above.\nrevokePermission(permissionId) | Revokes a permission identified by its `id`.\ndetectFields() | Updates the Stream field config (schema) to match the latest data point in the Stream.\npublish(message, timestamp, partitionKey) | Publishes a new message to this Stream.\n\n### Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\nName | Description\n---- | -----------\nstream    | Stream id to subscribe to\npartition | Partition number to subscribe to. Defaults to partition 0.\nresend | Object defining the resend options. Below are examples of its contents.\ngroupKeys | Object defining the group key as a hex string for each publisher id of the stream.\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Data Unions API\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\nName | Returns | Description\n---- | ------- | -----------\ndeployDataUnion() | Transaction | Deploy a new Data Union\ncreateSecret(dataUnionContractAddress, secret[, name]) | | Create a secret for a Data Union\ndataUnionIsReady(address) | | Wait until a new Data Union is initialized by its Operator\naddMembers(dataUnionContractAddress, memberAddressList) | | Add members\nkick(dataUnionContractAddress, memberAddressList) | | Kick members out from Data Union\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\nName | Returns | Description\n---- | ------- | -----------\njoinDataUnion(dataUnionContractAddress[, secret]) | JoinRequest | Join a Data Union\nhasJoined(dataUnionContractAddress[, memberAddress]) | | Wait until member has been accepted\nvalidateProof(dataUnionContractAddress, options) | true/false | Check that server is giving a proof that allows withdrawing\nwithdraw(dataUnionContractAddress, options) | Receipt | Withdraw funds from Data Union\nwithdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt | Pay for withdraw transaction on behalf of a Data Union member\nwithdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt | Donate/move your earnings to recipientAddress instead of your memberAddress\n\nThe options object for withdraw functions above may contain following overrides:\n\nProperty | Default | Description\n-------- | ------- | -----------\nwallet   | auth    | ethers.js Wallet object to use to sign and send withdraw transaction\nprovider | mainnet | ethers.js Provider to use if wallet wasn't provided\nconfirmations | 1  | Number of blocks to wait after the withdraw transaction is mined\ngasPrice | ethers.js | Probably uses the network estimate\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\nName | Returns | Description\n---- | ------- | -----------\ngetMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...} | Get member's stats\ngetDataUnionStats(dataUnionContractAddress) | {memberCount, totalEarnings, ...} | Get Data Union's statistics\ngetMembers(dataUnionContractAddress) | [{address, earnings}, ...] | Get Data Union's members\n\n\n### Utility functions\n\nName | Description\n---- | -----------\nStreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.\n\n\n### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n### Events on the StreamrClient instance\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nconnected |  | Fired when the client has connected (or reconnected).\ndisconnected |  | Fired when the client has disconnected (or paused).\n\n### Events on the Subscription object\n\nName | Handler Arguments | Description\n---- | ----------------- | -----------\nsubscribed | | Fired when a subscription request is acknowledged by the server.\nunsubscribed | | Fired when an unsubscription is acknowledged by the server.\nresending | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function.\nresent | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending.\nno_resend | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend.\nerror | Error object | Reports errors, for example problems with message content\n\n### Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning). \n\n**Creating partitioned streams**\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n**Publishing to partitioned streams**\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly. \n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on. \n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n**Subscribing to partitioned streams**\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n### Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`:\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n### Publishing `beta`:\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\nhttps://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created. \n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"cd43027205bd7e05bd6d08b032455e019a575b57","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-flakey":"jest --forceExit test/flakey","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.12.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","mem":"^6.1.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","p-limit":"^3.0.2","p-queue":"^6.6.1","p-memoize":"^4.0.0","quick-lru":"^5.1.1","node-fetch":"^2.6.1","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.1","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","node-webcrypto-ossl":"^2.1.1","node-abort-controller":"^1.1.0","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^6.0.4-alpha.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.12.3","geckodriver":"^1.20.0","jest-circus":"^26.6.3","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.12.1","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.1_1605910303089_0.883798976941442","host":"s3://npm-registry-packages"}},"5.0.0-alpha.2":{"name":"streamr-client","version":"5.0.0-alpha.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.2","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1c572dce11c3334abb1f72001a5068cf77e44dc7","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.2.tgz","fileCount":101,"integrity":"sha512-f4mIzZXdxuis8d+iWe6JytwliVo5mjrXg20THHreU9rKE7QFBn6hl5EcGm91zlQ1/6rYCJ7tgjFx6AphQG2Pjw==","signatures":[{"sig":"MEUCICvJijH4R3AYS/XgIXvjSLZigPMfzo14J4trpwWlDFqoAiEAzNWb+PMnb9mxEX5FyC6Vpgq48BiZVZGD6wHfZLKJJ9E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10140383,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuEJ0CRA9TVsSAnZWagAAJNQP/jCvmCw6YQ+vjOCoRi84\nULARf1fk+MKRMpVCcsDfrCjObKTio9gLM/lI00XrIDOdwg3FP+VThSWLY/s4\nUDnaLYDpAIEQbMubgb47BPc6ej5Q0nFmT7c3o2HPaZag6BocKL/D9IWh7Hh3\n2lVC1W/GkKAnw//686vX3Q+8PRwSIUcdL+ODNjnYuf2mkq2/nwXeorWtd4sw\nSsDFTPNp8K92Qo1whuVi/mr6y9RK41f1HGyV+54yFbFapowGTLn6zCEmNQAf\nEnIK2eL2mSsknCd5xeoHIWHQCw9TyToRYW6GhL5dC8DOIsxl2dOnFCidvpYz\nQIR1NSzjau5Fx+0yGBbyW8I3slXNFBetZPMoG3k9zV5RgorGrOmx2Kc+e4XR\nJmm0HzEXOjDczCXqG5hYoIbFuaJYRDhreIyF+iORQhLZTmoyem5Jfe2XVcBc\nzmZgaza/CKXeqxnovKeQj4JiK8J/H/5HylkDlHVRoCJ5oBn0wjs4WlF7Rzdr\nZtq2TXHrycHNNZ9isCwX882Q+nxNVoLcWqpaUrM9OtemziefkeJw0Xi9fyeL\n4alnRkOmRoHp9Vz/lRa/ZX876BaCPKWatWToP/USOqzPBUWWxX0V5/SPUA5b\nXEANWNnHdPOa+2BnDw4a+H0rawEPk4yyr3HjT8VENpc+C5DvdmozT6Eirq86\nYAbX\r\n=T8ys\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n\n(Authenticating with an username and password, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\n| Name                                                    | Returns     | Description                                                |\n| :------------------------------------------------------- | :----------- | :---------------------------------------------------------- |\n| deployDataUnion()                                       | Transaction | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])  |             | Create a secret for a Data Union                           |\n| dataUnionIsReady(address)                               |             | Wait until a new Data Union is initialized by its Operator |\n| addMembers(dataUnionContractAddress, memberAddressList) |             | Add members                                                |\n| kick(dataUnionContractAddress, memberAddressList)       |             | Kick members out from Data Union                           |\n\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\n| Name                                                         | Returns     | Description                                                  |\n| :------------------------------------------------------------ | :----------- | :------------------------------------------------------------ |\n| joinDataUnion(dataUnionContractAddress[, secret])            | JoinRequest | Join a Data Union                                            |\n| hasJoined(dataUnionContractAddress[, memberAddress])         |             | Wait until member has been accepted                          |\n| validateProof(dataUnionContractAddress, options)             | true/false  | Check that server is giving a proof that allows withdrawing  |\n| withdraw(dataUnionContractAddress, options)                  | Receipt     | Withdraw funds from Data Union                               |\n| withdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt     | Pay for withdraw transaction on behalf of a Data Union member |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt     | Donate/move your earnings to recipientAddress instead of your memberAddress |\n\nThe options object for withdraw functions above may contain following overrides:\n\n| Property      | Default   | Description                                                  |\n| :------------- | :--------- | :------------------------------------------------------------ |\n| wallet        | auth      | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet   | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | 1         | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js | Probably uses the network estimate                           |\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                           | Description                 |\n| :--------------------------------------------------------- | :--------------------------------- | :--------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}            | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {memberCount, totalEarnings, ...} | Get Data Union's statistics |\n| getMembers(dataUnionContractAddress)                      | [{address, earnings}, ...]        | Get Data Union's members    |\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"29f9485088cce77bc10ea5d187746b171a79e1e9","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-flakey":"jest --forceExit test/flakey","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.12.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","mem":"^6.1.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","p-limit":"^3.0.2","p-queue":"^6.6.1","p-memoize":"^4.0.0","quick-lru":"^5.1.1","node-fetch":"^2.6.1","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.1","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","node-webcrypto-ossl":"^2.1.1","node-abort-controller":"^1.1.0","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^6.0.4-alpha.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.12.3","geckodriver":"^1.20.0","jest-circus":"^26.6.3","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.12.1","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.2_1605911156131_0.7415497425868567","host":"s3://npm-registry-packages"}},"5.0.0-alpha.3":{"name":"streamr-client","version":"5.0.0-alpha.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.3","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9a6851ef4dacde09244e9580aba218d8f34571e6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.3.tgz","fileCount":107,"integrity":"sha512-OSh/fD5dkVgYNrZCq4r/jcuHTshY8cOpkWwct9dD1UGzCBoUdsU8KRESezmWiWhTAFq0q0H0zdeUNgZ15Y0T4w==","signatures":[{"sig":"MEUCIQDAsDoPZPJrmcDmvM5e5dIOlrXMr1tm5/7cAPMCrAWK4AIgB1BspZVh3B+rHuNFZGqt1dcXbM33verQ2B00Iublu6g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9717774,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfvU7/CRA9TVsSAnZWagAAk0AQAJW+d/o12UhJaTY1CR0M\nkPAcEB93Li2TJawVi6gnHvbS+3QKD97fw6oPQuvLtd3mabMwBgqrgykzGSYO\npgkskkMISop4HzPGFOX8j0MWMAaoldIj76vs0ECq2g4/WhLgMhUSJQOVDHqL\ngO9pX/QOMZoiv+murfOD34siJ+jq21koO+8XIlbxirOwts6huDmMXQkA8j+Q\nIZv0kgk+mJFBFtS9LDWEibXsMU2A/gvnZAtkMoIzzGL1wB0+W1LfGfi90cFs\nRYrh5x+JCwlwlX1Q1+tRoz9xKinTWCDehUdhaG6xnHOcIUVM96p+Q6jukGFM\nojHXPqN4AMPjjvJjqLAsQ8PWU9SwSdp8oY1/w4rsV6wq44gUDcMODzz6T7C5\nwHmqbyjLSr4Ym38gzKQakf93BAALWQ48FKu3Qlf7m/QQFb5y7zmgZ/yBkgqr\n5sXBcYKNTEpzdDEXoIWxrLNaO7wUjBsJiH2+aZHCow87HyruQCFivUMOvCv3\nVrThBlnPJQIrJU+aaEqJuxAupqjC9b3SOnDMy3iCs/zK6dcKKSEcbJFBJJER\nAjYPbKnh751XTSgM7tElVNymVgEQB5+sFUwUxJnQoEiZ/oolh6QGkz8qRpXE\no9pZMNEaeJDsmzlOuaaIPyVFXbkd2nyIM1UQctXvpvA08i/jd/tFGrSsUDj4\n7cpS\r\n=yda3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n\n(Authenticating with an username and password, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\n| Name                                                    | Returns     | Description                                                |\n| :------------------------------------------------------- | :----------- | :---------------------------------------------------------- |\n| deployDataUnion()                                       | Transaction | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])  |             | Create a secret for a Data Union                           |\n| dataUnionIsReady(address)                               |             | Wait until a new Data Union is initialized by its Operator |\n| addMembers(dataUnionContractAddress, memberAddressList) |             | Add members                                                |\n| kick(dataUnionContractAddress, memberAddressList)       |             | Kick members out from Data Union                           |\n\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\n| Name                                                         | Returns     | Description                                                  |\n| :------------------------------------------------------------ | :----------- | :------------------------------------------------------------ |\n| joinDataUnion(dataUnionContractAddress[, secret])            | JoinRequest | Join a Data Union                                            |\n| hasJoined(dataUnionContractAddress[, memberAddress])         |             | Wait until member has been accepted                          |\n| validateProof(dataUnionContractAddress, options)             | true/false  | Check that server is giving a proof that allows withdrawing  |\n| withdraw(dataUnionContractAddress, options)                  | Receipt     | Withdraw funds from Data Union                               |\n| withdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt     | Pay for withdraw transaction on behalf of a Data Union member |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt     | Donate/move your earnings to recipientAddress instead of your memberAddress |\n\nThe options object for withdraw functions above may contain following overrides:\n\n| Property      | Default   | Description                                                  |\n| :------------- | :--------- | :------------------------------------------------------------ |\n| wallet        | auth      | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet   | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | 1         | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js | Probably uses the network estimate                           |\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                           | Description                 |\n| :--------------------------------------------------------- | :--------------------------------- | :--------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}            | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {memberCount, totalEarnings, ...} | Get Data Union's statistics |\n| getMembers(dataUnionContractAddress)                      | [{address, earnings}, ...]        | Get Data Union's members    |\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"e516b99f197f796a1090054ce9f2bd1dfa41d02c","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-flakey":"jest --forceExit test/flakey","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.12.0","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","ethers":"^5.0.21","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","node-webcrypto-ossl":"^2.1.2","node-abort-controller":"^1.1.0","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.0.0-alpha.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","eslint":"^7.14.0","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.3_1606242046406_0.11825852466999831","host":"s3://npm-registry-packages"}},"4.2.0-alpha.12":{"name":"streamr-client","version":"4.2.0-alpha.12","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.12","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2f4425acfc05f27acefb1c05a2eff5c1497e05bc","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.12.tgz","fileCount":117,"integrity":"sha512-er0aIMTQ3O3Op9p71iFELeI+2T3Qdmbj80FV7hA6m4fcMjgvx3blBFyS4DNbwkokkB9BokJi60pSlRfFDlKtjw==","signatures":[{"sig":"MEUCIQCzhRJ5gZcGP6y+A3IJ57F57IJqIpLSvcjab6vaeIJF2AIgVsmWWDTHl5TlhgeKPmWjS+Epeui3MpV7SebA4l1YrBo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11099313,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfwKpxCRA9TVsSAnZWagAAHd0QAI30rPBjz5gmL1/xLd89\nkQl879/re5AluTgR+5ObJqy2TlNoPNafEkW+7r/ibU++WJ/iRT7EkzMq4TKH\nyJA7BIeeialnkXTeczfPNZtxPpQdlMXVxVB4odmb7n1lFqwAUV4emXHTa9H1\nVacXXhU8FawnCXYPlyIYdHltPyaqaRzzK/KP2PqkuFkYa9MRMz/i3hSgapkg\nQtGB6DMsIr1ulhE7wTUalj4FFeD6/vah25U/NbQnLxtx/MfSVvbRW8Sk3Nb5\nDuWXyAUkFJn22Vn8XU2nnqYgHg4qXM50KFubC7HnqPihAZ8H3VX/+j0vVbHS\ngvW7an5nyk5urtWfLu8WcoCG3/lh8EfMLwvLWuGphURfmtRTXJcWZQHGXTEL\nSyFXsoIeL0xG8hymu2acIN4bZAaZXH6KDtCecLI9x9euuecKd5AmiGLFnHvw\nEZs2dzHMYf/uiKJ/ae2QhnuGVL5+a2PjfNLBIjjkS7a/LAcHbj3sRTSGoPag\nR3YwvQreHDKduJptxvuMHh2ul6OIrLuKtXzYR05A09uozeJMeffig1e4kbT1\njN4f9puDcsw8ve/xhFZAq7o+RT84sMGtXS77YClZ27zI+jTmZYbfElp1Wjnl\naypt+U0AL9TyniC4Zw1dFrQzsOCtdcXJzJRijnSlL55O1p7aLoTekSFsB5ZX\nYQ7O\r\n=XAUP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated.** \n\n**Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n\n(Authenticating with an username and password, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\n| Name                                                    | Returns     | Description                                                |\n| :------------------------------------------------------- | :----------- | :---------------------------------------------------------- |\n| deployDataUnion()                                       | Transaction | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])  |             | Create a secret for a Data Union                           |\n| dataUnionIsReady(address)                               |             | Wait until a new Data Union is initialized by its Operator |\n| addMembers(dataUnionContractAddress, memberAddressList) |             | Add members                                                |\n| kick(dataUnionContractAddress, memberAddressList)       |             | Kick members out from Data Union                           |\n\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\n| Name                                                         | Returns     | Description                                                  |\n| :------------------------------------------------------------ | :----------- | :------------------------------------------------------------ |\n| joinDataUnion(dataUnionContractAddress[, secret])            | JoinRequest | Join a Data Union                                            |\n| hasJoined(dataUnionContractAddress[, memberAddress])         |             | Wait until member has been accepted                          |\n| validateProof(dataUnionContractAddress, options)             | true/false  | Check that server is giving a proof that allows withdrawing  |\n| withdraw(dataUnionContractAddress, options)                  | Receipt     | Withdraw funds from Data Union                               |\n| withdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt     | Pay for withdraw transaction on behalf of a Data Union member |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt     | Donate/move your earnings to recipientAddress instead of your memberAddress |\n\nThe options object for withdraw functions above may contain following overrides:\n\n| Property      | Default   | Description                                                  |\n| :------------- | :--------- | :------------------------------------------------------------ |\n| wallet        | auth      | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet   | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | 1         | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js | Probably uses the network estimate                           |\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                                 | Description                 |\n| :-------------------------------------------------------- | :-------------------------------------- | :-------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}                  | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {activeMemberCount, totalEarnings, ...} | Get Data Union's statistics |\n| getMembers(dataUnionContractAddress)                      | [{address, earnings}, ...]              | Get Data Union's members    |\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"b9db77ddc926aea041b7337493b860cff31b3197","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.13.4","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"10.19.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/keccak256":"5.0.6","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.12_1606462064578_0.5603694335846479","host":"s3://npm-registry-packages"}},"5.0.0-alpha.4":{"name":"streamr-client","version":"5.0.0-alpha.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.4","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"23d1a993e8cb4439886248c109d8de48c50e52ec","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.4.tgz","fileCount":114,"integrity":"sha512-fvW3AXjjOQ2QrDY51MStFYlWz5Sv8zJdlqNWKe/+Q/DeLKNXNTeDSXxiUhdEL5qNAgBpTYEFVHkpL6WFTKn/hw==","signatures":[{"sig":"MEYCIQDffZIhk3YdigHEuqfVsyS4Z6Nk6VNTDvbLHoLdy9MAlwIhALOoTYwj85MtGnxDnivHzQ4o4k9QkwbRGTJYfChxDDVT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13808054,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxmOGCRA9TVsSAnZWagAASW0P/Aklm+OAgnmCfV+2egxB\nczsJB0wT/mI6YvazxjpEOVpLKc5wGllzPpXB+cYhwzIf/7iKTjRcNGlj2Nd0\nZTxhvmH+Bc4x03Bx4NKK4QcYqygb3jTxrP4OT+oEn9QQVdUUy/EHmZm71R2D\nj3qA2k8C9u8vI18BrGqKx0QcHi7N0YWDLbyc0oE6JCO6k7mOAzbQYdVR5FhW\nP0lF/7w3D2HkIdvZd4ynU8iS4xP8RzOaV+5IKuqTGvxtaIf6PvOMrnqJzp6d\nRGNWAj94U6aiAfQzEqlkW1LbQPrwpfRKUQwjI69b3K/LrtjT10c7F4dJ25oL\nf2any56Rn0L35FsamkGitV+bzXFy3ljTimQWLBLEqPmRvJv7jDAnyy0bGbvE\nzDhB/Oq/H6TGkY8QQ2tPrQzznVxcAO1h2+YR6HxqrwmZVQoPu0qeusA7SEx5\nXD8+l8vgaVoAShjf4IeaTgwGZUMCYFiPTrKgS7qPNzg6J2+mKHpHK/9DlPpP\n6dRvDBIWmykSwJo3sVT6mLOKnd7Yjp60fkwTnp7cYLiH6d0msuTwlXz0WhxK\nf00QINVbicdzM/RPr75dkU2Klo41KJC7Rs2vyH24WW8Q08adY8whYzz5YwCO\nijPgtkJqGklUnuY/dEJroVHMFX/DBBqE1I2ykXDdTO+603c8cwNUpksthI/J\nWkn7\r\n=QtMi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated. Support for email/password authentication will be dropped in the future with authentication by cryptographic keys/wallets will be the only supported method of authentication.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n\n(Authenticating with an username and password, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\n| Name                                                    | Returns     | Description                                                |\n| :------------------------------------------------------- | :----------- | :---------------------------------------------------------- |\n| deployDataUnion()                                       | Transaction | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])  |             | Create a secret for a Data Union                           |\n| dataUnionIsReady(address)                               |             | Wait until a new Data Union is initialized by its Operator |\n| addMembers(dataUnionContractAddress, memberAddressList) |             | Add members                                                |\n| kick(dataUnionContractAddress, memberAddressList)       |             | Kick members out from Data Union                           |\n\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\n| Name                                                         | Returns     | Description                                                  |\n| :------------------------------------------------------------ | :----------- | :------------------------------------------------------------ |\n| joinDataUnion(dataUnionContractAddress[, secret])            | JoinRequest | Join a Data Union                                            |\n| hasJoined(dataUnionContractAddress[, memberAddress])         |             | Wait until member has been accepted                          |\n| validateProof(dataUnionContractAddress, options)             | true/false  | Check that server is giving a proof that allows withdrawing  |\n| withdraw(dataUnionContractAddress, options)                  | Receipt     | Withdraw funds from Data Union                               |\n| withdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt     | Pay for withdraw transaction on behalf of a Data Union member |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt     | Donate/move your earnings to recipientAddress instead of your memberAddress |\n\nThe options object for withdraw functions above may contain following overrides:\n\n| Property      | Default   | Description                                                  |\n| :------------- | :--------- | :------------------------------------------------------------ |\n| wallet        | auth      | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet   | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | 1         | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js | Probably uses the network estimate                           |\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                           | Description                 |\n| :--------------------------------------------------------- | :--------------------------------- | :--------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}            | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {memberCount, totalEarnings, ...} | Get Data Union's statistics |\n| getMembers(dataUnionContractAddress)                      | [{address, earnings}, ...]        | Get Data Union's members    |\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"5250202e987c7f8c80d54b659d64156c955adb94","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","test-flakey":"jest --forceExit test/flakey","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.20.0","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","ethers":"^5.0.21","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","node-webcrypto-ossl":"^2.1.2","node-abort-controller":"^1.1.0","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.0.0-alpha.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","eslint":"^7.14.0","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.4_1606837126383_0.6311793982358627","host":"s3://npm-registry-packages"}},"4.1.4":{"name":"streamr-client","version":"4.1.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.4","maintainers":[{"name":"teogeb","email":"teo@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0c6fcd8f590004519a3acf4215d203e421f35963","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.4.tgz","fileCount":109,"integrity":"sha512-YMFxjC/I3KzU1uKiY4H4YoeIItBishVF7FN1t4VlXj0TQuWG67tWsluQw7hXHj6yI6tcv6cQ69I+TCXRtkgcMg==","signatures":[{"sig":"MEUCIQDoO11j/sQhwR08m4UeCLsaXnuLeWC0zQ8HvisvPCiaDAIgFAnJzCrDZc+Fl7OVPX3xIhJszx54d9R6XnnQCQAmpYM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7184196,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfz56pCRA9TVsSAnZWagAAZdAP/06H1trQHka49VLnz1hU\n8XZc3JU8lRfuqbm4jBplQSZcA5UZDWa1+yk29PuqnILYpLxMa1K5GupyXIQj\nfUmuhmlRDG1mdwJ9LHWHxPPi3V3TPtwDLSK2KEA1xa1loYy1OaAtqTjRUqb2\nCn2xB2izzf9VEeTcrNR+jgRpSmXivwwVR+dMeVFF3yNZDURVRWDrf+i1UOpj\nvIAZuIhLr/fEeT64YxitYrPtmkm1MlxmZo24/p4u8kMFgl/xNRIfpv83GTGa\nNafQ77kyPs++bAG+Bd1grFa13pmBIcOwsZjqxqCDhQEJJCtppxsoAwxsz587\n2OhAxupGO5p9oQ+seigM4bE5dp2A1bkAwZpzr1nDPbvWam0IQPIIznSS1FYa\nUXLc4PCoAu5HtzDRpD1toli8q0ejShdGxcRHOdGPOcyseboa9BI0F0WNgYEH\nApjl9oh59hvPlmw5oMKVGCZkvQlPDEUnCGl8+a1KYwAVkj9mwPq0k7rx96wm\ngM0g4nyaVBR2idYn0C9hmyMm8UvZcqllF0JfuBv1pxB9/RPdUe4qdKvmRuw2\nlA2pkB0rB/mCocUygEazFOvDWJzXK40vLNoSaiRtumWy3dOWaR2kWj4APZ9e\nmt42ImdZ11JmvtqTT2daQ/dc7l1Tp6b0Yds5qDBib9NaAaH3y4dpQXaHBqX9\nTGKC\r\n=OFPs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"45d9659c3d84fcbe0a885015f78840e9334657ca","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.15.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^85.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.4_1607442089331_0.4655128478292456","host":"s3://npm-registry-packages"}},"4.2.0-alpha.13":{"name":"streamr-client","version":"4.2.0-alpha.13","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.13","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"921035e80c0d0478109af20dc6805bf26612b19c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.13.tgz","fileCount":118,"integrity":"sha512-3Wk7UozSkEWhgwri0us5u+eI/o6auYIu3ySY9y5+pGw/GBWV9jJgMJ03BVDFbobKdGdWWsp1TWArt24Oy7FJ0A==","signatures":[{"sig":"MEYCIQCutTsLNVgAW9p/aNETd64n90O5WSv6gcNCXvUSWrr1DwIhAKXF5LhYt70sprzzvoAdmercZaPfTMZkqVHE5f/unTkq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11234866,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3LfUCRA9TVsSAnZWagAAzwkP/0EIWJLBKfS+X4Rr1A13\n06pfDKFPoAm2y9mn+vF4VRcSBSWH3TqYVyY+m0GvbelbNThbYEgori9GWXLU\nnVHSFL/YMqDLqSoOmTmdAKQ3LXTwyEmnIulqp/ErawOa0sSnb1KJme5iL/Ky\ng4o62XXaexYE6mSdn2z5SJ7T84kQ3sLbk8B96lhLyGS/tmjDmex1TKOdTXUm\neWdZ2Hs03m84RadHBspuPvBjUppsqxl2oQqYXEMCB27RRvFTNlmqkVGnc6TN\n/5Og7GOO5owButcQPTVvMaDJSDfYiaLnDkxfwvdGVUzi/TbpBsD4QO1Nqvur\nY3XwCMuflLmwVuTqUqHlHXmN5XDh/m5lJetjtcqGNetHJ4c5FIUYVeWJteDb\nkd12hRIguc5f5ZCKlRGSnIVdMk+MSaBt36f0UDgfh3jSyxCVR20RVjZuH1+S\nIvWPxozkz3LO++0ZRUYA7OFV1T4urFp5xHlJD05Za2+bIV92R/gMQDBPR6mO\ncItEApemscfPFXZsw0/GsEmq4O5vCDfi6PSladpeO06l7YU8gpmwe+jw7UL9\nXy/OZ/HtmS4WxJDdyg+aOGLdMQAiDyWYCVjPfJ1LkSpbmxXAwKuExg3AIjN1\noHRtOYpbetMg2Iq41GNwh6Yo4humH2aA7U6J84nBBg2RYheuyi9xYvOkruxP\nkZ+t\r\n=HOdI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        apiKey: 'secret',       // Optional. If not given, uses the apiKey given at client creation time.\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated.** \n\n**Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nAuthenticating with an Ethereum private key by cryptographically signing a challenge. Note the utility function `StreamrClient.generateEthereumAccount()`, which can be used to easily get the address and private key for a newly generated account. Authenticating with Ethereum also automatically creates an associated Streamr user, if it doesn't exist:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: web3.currentProvider,\n    }\n})\n```\n\n(Authenticating with an username and password, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        username: 'my@email.com',\n        password: 'password'\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result. They can also take an `apiKey` as an extra argument. Otherwise the `apiKey` defined in the `StreamrClient` options is used, if any.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\n| Name                                                    | Returns     | Description                                                |\n| :------------------------------------------------------- | :----------- | :---------------------------------------------------------- |\n| deployDataUnion()                                       | Transaction | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])  |             | Create a secret for a Data Union                           |\n| dataUnionIsReady(address)                               |             | Wait until a new Data Union is initialized by its Operator |\n| addMembers(dataUnionContractAddress, memberAddressList) |             | Add members                                                |\n| kick(dataUnionContractAddress, memberAddressList)       |             | Kick members out from Data Union                           |\n\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\n| Name                                                         | Returns     | Description                                                  |\n| :------------------------------------------------------------ | :----------- | :------------------------------------------------------------ |\n| joinDataUnion(dataUnionContractAddress[, secret])            | JoinRequest | Join a Data Union                                            |\n| hasJoined(dataUnionContractAddress[, memberAddress])         |             | Wait until member has been accepted                          |\n| validateProof(dataUnionContractAddress, options)             | true/false  | Check that server is giving a proof that allows withdrawing  |\n| withdraw(dataUnionContractAddress, options)                  | Receipt     | Withdraw funds from Data Union                               |\n| withdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt     | Pay for withdraw transaction on behalf of a Data Union member |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt     | Donate/move your earnings to recipientAddress instead of your memberAddress |\n\nThe options object for withdraw functions above may contain following overrides:\n\n| Property      | Default   | Description                                                  |\n| :------------- | :--------- | :------------------------------------------------------------ |\n| wallet        | auth      | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet   | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | 1         | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js | Probably uses the network estimate                           |\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                                 | Description                 |\n| :-------------------------------------------------------- | :-------------------------------------- | :-------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}                  | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {activeMemberCount, totalEarnings, ...} | Get Data Union's statistics |\n| getMembers(dataUnionContractAddress)                      | [{address, earnings}, ...]              | Get Data Union's members    |\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"160ea73b0ff44edac2cb4428441be09e5e55d1ff","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.20.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/keccak256":"5.0.6","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.13_1608300499980_0.831025726934393","host":"s3://npm-registry-packages"}},"5.0.0-beta.1":{"name":"streamr-client","version":"5.0.0-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"64a052f95c3acd4b42dc111e1653bf2567750bdc","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.1.tgz","fileCount":116,"integrity":"sha512-pvWClZoGDviOPO2/h1AyDfJ2fGbonyR4Bn7eaYgEl+CfmAIVuf8JHfi8qGdoRfOw5osZY1QgTCdcfF0aeoeAYg==","signatures":[{"sig":"MEUCIQDlMUGBS6QHjcbkhW6Sh8EH1yckIFZp61Lai9y//LaDxQIgfU3kX/ePOm/Z/siU3xRxe6wXWqUupb1XKK1yt3C+e8w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14154060,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3Py3CRA9TVsSAnZWagAA7SkP/00UAGVX3fhES6jkpLZH\n2hl/AELxGqmFo1+qPOypmdEgHe7tD2UVhxRAPHgO9DlVHhAGIZaFQdp0lszx\nW4pJDqjrY14OMzw2i+TYF6ud6vWY3nCA2G/Gel5DTnc45jLly5L5BEC/WOio\nltfmsygg5R3aJzTKDUWK7/XPZmCLvQlRNzftNCjmwKqQXi3ka+8cSQKVnSAo\nZAxZ47gssQIFPR+3E6/ffyaa1HJz1w/4eUX2bVcFKcgH6+U8rv5AtwZvjFEC\n3eOznF8KIiEjUWNYRKbGgItOfCUGikKIoZbfKrv80jq24mA3Z+3f/fbHNmpc\n8b8IqNXMaEq/VVQopfKbt/eWJ6e/8nHv1a+V/OmCrSbGf6aP7XTE6vJi9IDx\ngm0tCPuEEvHmjXrzskteRcNsSUvvIrFlUXA7Hg6KjHRllzwP6tz0eY6aDCYg\n+c4X/iZZh4wfS86DiCbcyD2yjMgtbiRXbcvQa5XQIcnMJ0onS5NsAo82AJrE\n6JyVQusXE9tfx2/7Za5HLGjooe14Q2jTf79QPxOAUsXn0raqvkhz08ikR7Zm\nXyWHYrdbBoHCWWlC4gxgpPcMzs7TolvOPcMbMVqnWIKYs4qkWEJd/wRdvZOy\n0B+U43rrcy441gN2ItAMMEU4iuGKo50p6DoDSIMN+8ukOlytlPGCHg+UI7NI\nEZxo\r\n=OwVj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n- Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n- Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n- Dec 31st 2020: Support for API keys will end.\n- Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated.** \n\n**Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. All of the below methods return a Promise.\n\n#### Admin functions\n\n| Name                                                    | Returns     | Description                                                |\n| :------------------------------------------------------- | :----------- | :---------------------------------------------------------- |\n| deployDataUnion()                                       | Transaction | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])  |             | Create a secret for a Data Union                           |\n| dataUnionIsReady(address)                               |             | Wait until a new Data Union is initialized by its Operator |\n| addMembers(dataUnionContractAddress, memberAddressList) |             | Add members                                                |\n| kick(dataUnionContractAddress, memberAddressList)       |             | Kick members out from Data Union                           |\n\n```javascript\nconst dataUnion = await client.deployDataUnion()\ndataUnion.address           // already available before deployment\nawait dataUnion.deployed()  // waits until contract is deployed\nawait dataUnion.isReady()   // waits until data union is operated\n```\n\n#### Member functions\n\n| Name                                                         | Returns     | Description                                                  |\n| :------------------------------------------------------------ | :----------- | :------------------------------------------------------------ |\n| joinDataUnion(dataUnionContractAddress[, secret])            | JoinRequest | Join a Data Union                                            |\n| hasJoined(dataUnionContractAddress[, memberAddress])         |             | Wait until member has been accepted                          |\n| validateProof(dataUnionContractAddress, options)             | true/false  | Check that server is giving a proof that allows withdrawing  |\n| withdraw(dataUnionContractAddress, options)                  | Receipt     | Withdraw funds from Data Union                               |\n| withdrawFor(memberAddress, dataUnionContractAddress, options) | Receipt     | Pay for withdraw transaction on behalf of a Data Union member |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Receipt     | Donate/move your earnings to recipientAddress instead of your memberAddress |\n\nThe options object for withdraw functions above may contain following overrides:\n\n| Property      | Default   | Description                                                  |\n| :------------- | :--------- | :------------------------------------------------------------ |\n| wallet        | auth      | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet   | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | 1         | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js | Probably uses the network estimate                           |\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                           | Description                 |\n| :--------------------------------------------------------- | :--------------------------------- | :--------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}            | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {memberCount, totalEarnings, ...} | Get Data Union's statistics |\n| getMembers(dataUnionContractAddress)                      | [{address, earnings}, ...]        | Get Data Union's members    |\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"9383af01c630b9d859557ed4977bf1d9b232a1fe","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ . ","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","ethers":"^5.0.21","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","node-webcrypto-ossl":"^2.1.2","node-abort-controller":"^1.1.0","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.0.0-alpha.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","eslint":"^7.14.0","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.2.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.1_1608318134632_0.6331992536776729","host":"s3://npm-registry-packages"}},"4.2.0-alpha.14":{"name":"streamr-client","version":"4.2.0-alpha.14","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.2.0-alpha.14","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a4e294f52c9b13446eae12c7a4e44c00ecd197d9","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.2.0-alpha.14.tgz","fileCount":118,"integrity":"sha512-cH1ffseqwFc+C1dSYtHQduNWCD7MmG54/dgH0oeRBFiRS/BfOczsq1lt9/TF04ySBY2I3CabMiN5I4Q6QT4epg==","signatures":[{"sig":"MEQCIF7q6zAE78o9/W1J57ApmgFETln9Y7YPnvUFba9Eu93kAiA8cysw00m9KLCXf9TMlLctrbi4RVnR5TdvZ9LA71CMdQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11246683,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAIgnCRA9TVsSAnZWagAADzoP/AwkxPpiL0Vk22TVZti9\niExhzMVArzOd3GwwlvRqXXoyCtjGWajW+O3vZ+juCeHk1nBh4+OC8PxvpBoT\nkAYzwrkXWfmzfUzxUwCv9bF4vO8LYsLy7ru5v3mEt26kob8MkCl74Z6i9DpI\nR5Zw4G/CgKEi5k+XyRf/0kuK1Sot5FF7FZpTFL2viHozxV+f/fWtK7/GaNEV\naYv9vIz4YApc4u3UgQa+MWkX+4pui16pu3IqNBV8bXo5lWSmIGtJyPE1s1NJ\n5bDo6YOokJRESBiX/Qz0C4e/ehxraufSRqpwt4Inm07tDWB+BvN6FxNGsQMJ\nNNH54fbt8OYfo/YAbsSA4WCBVcZ6CwlYTAwXWjV6JUXA5ksViEMre6eAcuaE\nx/MkiMI2yXxnOUmjeOI3Mb6vKlJ3kXywGFgA0UOSq35Xy1XXnrieYXZZq9Z2\nzN7QPqL+3W0/FcTzohtgrId/EwHxgxyp2YZFQu8/+u12zaHBZuCAR3o3Rn7c\ntlPqj8MszqPREPMYHQH7qHdnlnghJQ16vYU8TNGbiAAPTX6KPsDk/vIoZlwb\nPHm9158l48ptEpL8TBbkD65oqeGzQm6IgxJ2gGnCuAVI7t0PnsN6Z9mPBqUE\nBysURfho6T4z1xxg5ZBUZiDqO7PvHa7EoY8Yk88l441gYfFMHniKQsGpZwDs\ny5CJ\r\n=wzm1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n- Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n- Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n- Dec 31st 2020: Support for API keys will end.\n- Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated.** \n\n**Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions.\n\nTODO: check all this documentation before merging/publishing, probably some of it is out of date (DU1 era)\n\nData union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function.\n\n| Property      | Default               | Description                                                  |\n| :------------ | :-------------------- | :------------------------------------------------------------ |\n| wallet        | given in auth         | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet               | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | `1`                   | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js supplied    | Probably uses the network estimate\n| dataUnion     | -                     | Address or contract object of the data union that is the target of the operation\n| tokenAddress  | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU\n| minimumWithdrawTokenWei    | 1000000  | Threshold value set in AMB configs, smallest token amount that can pass over the bridge\n| sidechainTokenAddress      |  TODO    | sidechain token address\n| factoryMainnetAddress      |  TODO    | Data Union factory that creates a new Data Union\n| sidechainAmbAddress        |  TODO    | Arbitrary Message-passing Bridge (AMB), see [Tokenbridge github page](https://github.com/poanetwork/tokenbridge)\n| payForSignatureTransport   | `true`   | Someone must pay for transporting the withdraw tx to mainnet, either us or bridge operator\n\n#### Admin functions\n\n| Name                                                      | Returns               | Description                                                |\n| :-------------------------------------------------------- | :-------------------- | :--------------------------------------------------------- |\n| deployDataUnion(options)                                  | Dataunion contract    | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])    |                       | Create a secret for a Data Union                           |\n| addMembers(memberAddressList, options)                    | Transaction receipt   | Add members                                                |\n| kick(memberAddressList, options)                          | Transaction receipt   | Kick members out from Data Union                           |\n| withdrawMember(memberAddress, options) |||\n| withdrawToSigned(memberAddress, recipientAddress, signature, options) |||\n| setAdminFee(newFeeFraction, options)                      | Transaction receipt   | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```javascript\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n#### Member functions\n\n| Name                                                              | Returns       | Description                                                   |\n| :---------------------------------------------------------------- | :------------ | :------------------------------------------------------------ |\n| joinDataUnion(options)                                            | JoinRequest   | Join a Data Union                                             |\n| hasJoined([memberAddress], options)                               |  -            | Wait until member has been accepted                           |\n| withdraw(options)                                                 | Transaction receipt   | Withdraw funds from Data Union                        |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options)   | Transaction receipt   | Donate/move your earnings to recipientAddress instead of your memberAddress   |\n| signWithdrawTo(recipientAddress, options)                         | Signature (string)    | Signature that can be used to withdraw tokens to given recipientAddress       |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei, options)   | Signature (string)    | Signature that can be used to withdraw tokens to given recipientAddress       |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```javascript\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\nconst signature = await client.signWithdrawTo(recipientAddress)\n```\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                                 | Description                 |\n| :-------------------------------------------------------- | :-------------------------------------- | :-------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}                  | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {activeMemberCount, totalEarnings, ...} | Get Data Union's statistics |\n| ~~getMembers(dataUnionContractAddress)~~                  | | NOT available in DU2 at the moment    |\n| getAdminFee(options)                                      | `Number` between 0.0 and 1.0 (inclusive)| Admin's cut from revenues   |\n| getAdminAddress(options)                                  | Ethereum address | Data union admin's address   |\n| getDataUnionStats(options)                                | Stats object                            | Various metrics from the smart contract |\n| getMemberStats([memberAddress], options)                  | Member stats object                     | Various metrics from the smart contract |\n| getMemberBalance([memberAddress], options)                | `BigNumber` withdrawable DATA tokens in the DU | |\n| getTokenBalance(address, options)                         | `BigNumber`                             | Mainnet DATA token balance |\n| getDataUnionVersion(contractAddress)                      | `0`, `1` or `2`                         | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```javascript\nconst client = new StreamrClient({\n    dataUnion,\n})\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"57de0876d1662f78987db2f93d080c18eeedc58c","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest test/integration"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.20.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"5.0.19","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.1","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.0.0","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/keccak256":"5.0.6","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","async-mutex":"^0.2.4","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.2.0-alpha.14_1610647590757_0.3057892134402944","host":"s3://npm-registry-packages"}},"5.0.0-beta.2":{"name":"streamr-client","version":"5.0.0-beta.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5f8a9e9e92dd054962338971bac8d21bfc94158e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.2.tgz","fileCount":135,"integrity":"sha512-hQ1as/nh7gWpkRYLUpB2vR0gpnQkWOCoeCtzOos9QdOcX5tCfQXq/3lYgmkYGo1yryRgCgGf75+jzXoSLy2O/w==","signatures":[{"sig":"MEQCIAcyLVhBt5btHDlCbTNVA2XYewo1rcrieX5LaBKYbKwlAiAaqKHqV2lQmyMaZdhS67rJEcPbZ8jQ8J9fv3hGjPtp9Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17757325,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAedGCRA9TVsSAnZWagAA6VoQAJ9odHbVKrQ86b++M2Lo\nAD8TxG04bl6sEsCq+BQz0jph8tJX5hoTHLb7v8TWQFMfMGhyIb7Wi+t1yPV7\n50IWOOkMVKkfEF+ASj0GM3I1dtC3kEBzl2jAjJ5lgfgS5qLVahUFkix8QLWU\nQvXOAMsuUP7yCQrKUnQT3Hb3d6dhVyh/pOZTuiZbQtOgl/U/Ye9hekEkplKv\nh3lEN51n9bdTGe9DMqrw5nFiWHApk0pveIiwg+jbdeQWEnfCh9wNZcnbcYBI\nlGSh3XW/5YRFF5lmWxBt19wG+3k0Kwqho9kEDdE4C36LAM18kzMrbZDWQDIe\npvgIngkmFTjrqXSjH+qvnQ5b+X5bNjRlWSp0y+OWABUO9apLDVQ7YKDLU/hK\nojM9eXPSOblo0BaikYySsJCDPkKwGvY10osNcc3+sV5OSREB3poxpVfeVnG8\nChKSVWsfukyvbAobnS+D/SLw5n2N/p+r7SgepDQTY+TOX8ceW08MQhUVeFcU\n77V91mM0dtseJFsV/sPiPCjTnznvvPsElsiHHMd/UxppcUIWA0X0dz6C5bi5\n6udYNxkwPaYEmxkeNrmAqblXybDR8WRgtFYmRhHfvq52UBd7cYYqj612D0Cs\nBstemZAt4MgVW2QBFiOUL3n03j6GVOemCZ+o/BSPFaLhPNZm7SflRWFn727O\naupm\r\n=HcOT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n- Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n- Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n- Dec 31st 2020: Support for API keys will end.\n- Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated.** \n\n**Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions.\n\nTODO: check all this documentation before merging/publishing, probably some of it is out of date (DU1 era)\n\nData union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function.\n\n| Property      | Default               | Description                                                  |\n| :------------ | :-------------------- | :------------------------------------------------------------ |\n| wallet        | given in auth         | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet               | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | `1`                   | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js supplied    | Probably uses the network estimate\n| dataUnion     | -                     | Address or contract object of the data union that is the target of the operation\n| tokenAddress  | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU\n| minimumWithdrawTokenWei    | 1000000  | Threshold value set in AMB configs, smallest token amount that can pass over the bridge\n| sidechainTokenAddress      |  TODO    | sidechain token address\n| factoryMainnetAddress      |  TODO    | Data Union factory that creates a new Data Union\n| sidechainAmbAddress        |  TODO    | Arbitrary Message-passing Bridge (AMB), see [Tokenbridge github page](https://github.com/poanetwork/tokenbridge)\n| payForSignatureTransport   | `true`   | Someone must pay for transporting the withdraw tx to mainnet, either us or bridge operator\n\n#### Admin functions\n\n| Name                                                      | Returns               | Description                                                |\n| :-------------------------------------------------------- | :-------------------- | :--------------------------------------------------------- |\n| deployDataUnion(options)                                  | Dataunion contract    | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])    |                       | Create a secret for a Data Union                           |\n| addMembers(memberAddressList, options)                    | Transaction receipt   | Add members                                                |\n| kick(memberAddressList, options)                          | Transaction receipt   | Kick members out from Data Union                           |\n| withdrawMember(memberAddress, options) |||\n| withdrawToSigned(memberAddress, recipientAddress, signature, options) |||\n| setAdminFee(newFeeFraction, options)                      | Transaction receipt   | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```javascript\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n#### Member functions\n\n| Name                                                              | Returns       | Description                                                   |\n| :---------------------------------------------------------------- | :------------ | :------------------------------------------------------------ |\n| joinDataUnion(options)                                            | JoinRequest   | Join a Data Union                                             |\n| hasJoined([memberAddress], options)                               |  -            | Wait until member has been accepted                           |\n| withdraw(options)                                                 | Transaction receipt   | Withdraw funds from Data Union                        |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options)   | Transaction receipt   | Donate/move your earnings to recipientAddress instead of your memberAddress   |\n| signWithdrawTo(recipientAddress, options)                         | Signature (string)    | Signature that can be used to withdraw tokens to given recipientAddress       |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei, options)   | Signature (string)    | Signature that can be used to withdraw tokens to given recipientAddress       |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```javascript\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\nconst signature = await client.signWithdrawTo(recipientAddress)\n```\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                                 | Description                 |\n| :-------------------------------------------------------- | :-------------------------------------- | :-------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}                  | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {activeMemberCount, totalEarnings, ...} | Get Data Union's statistics |\n| ~~getMembers(dataUnionContractAddress)~~                  | | NOT available in DU2 at the moment    |\n| getAdminFee(options)                                      | `Number` between 0.0 and 1.0 (inclusive)| Admin's cut from revenues   |\n| getAdminAddress(options)                                  | Ethereum address | Data union admin's address   |\n| getDataUnionStats(options)                                | Stats object                            | Various metrics from the smart contract |\n| getMemberStats([memberAddress], options)                  | Member stats object                     | Various metrics from the smart contract |\n| getMemberBalance([memberAddress], options)                | `BigNumber` withdrawable DATA tokens in the DU | |\n| getTokenBalance(address, options)                         | `BigNumber`                             | Mainnet DATA token balance |\n| getDataUnionVersion(contractAddress)                      | `0`, `1` or `2`                         | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```javascript\nconst client = new StreamrClient({\n    dataUnion,\n})\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"8bff901f914cf42cb957d781bbd2f1c37f84125e","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ . ","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey/*","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --testTimeout=15000 test/integration/DataUnionEndpoints"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","buffer":"^6.0.3","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/sha2":"5.0.3","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"5.0.3","@ethersproject/wallet":"5.0.6","node-abort-controller":"^1.1.0","@ethersproject/address":"5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.1.2","@ethersproject/bignumber":"5.0.6","@ethersproject/contracts":"5.0.3","@ethersproject/keccak256":"5.0.6","@ethersproject/providers":"5.0.14","@ethersproject/transactions":"5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","eslint":"^7.14.0","ethers":"^5.0.21","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","async-mutex":"^0.2.4","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.2.0","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.2_1610737477199_0.07709568579948844","host":"s3://npm-registry-packages"}},"4.1.5":{"name":"streamr-client","version":"4.1.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"d5563ed4779e95eb80d756401f5e715d8a9bffbc","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.5.tgz","fileCount":107,"integrity":"sha512-Ic3k26k0vJ3xVyf4sAYxFMOTrRB/j00Iaz1jXg2/RW3VZ4s17v74b0xBu1G2g89BebzE9/i1gceuHkI0FaiEkw==","signatures":[{"sig":"MEQCIHCtZW1p4miFNUR9SdP8gz+0Cj8RMtZYQOEne0VvozgGAiB/x6sykTHXjzWXNn0MW5Frjj7oXSyuJahe0XXATI8Euw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6957674,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBkcYCRA9TVsSAnZWagAAGLYP/3rad8ITK0k7HfBiRlgx\nkR82yy5Q8B1lwl/mN/EuuDlogQPZoRg4+R3m6c8G9HmBjvPYJ+Kzm3u+/HHz\nMnFA1qf4IZxj1uwCFK2nxPbNh75fFCEi8eENTudsI91bjQbm8OoH5Ke3lFEs\nYfFdX9zlHImiHeXGoZrwiTgOEC1MbLBdI1S3n0sqtkWw2f2R5bCVWtKRGoOv\ncWLY1bO3ntNbJMxNw6NJKW4vXetlpGp8jPXdWZhUFurwVl7M5flGFjEOKOtb\nVJO499fFaFfy/hXKJFTOHGGgMu2IMklUR/KgQVwzuocCQT65ENIcU/JvhtKE\nC6yDHLfK7SkqtdXj7+Xqap+Kws/JKiSxye4fzozXA5Z7ADlXKghy4WB/D7pG\n5n/NPNqLCzHCQJGr76iB1uuyNPC7hR/aFhShWOYFG1qZVSrWkA6Ym1DkQpPT\n9075inK4K384ORYCboQ5bm0u2fJg4+o7XoaxSOHvWNnUX9zD6mRPWPrw1GDE\nwY2ADTzBUgoPncrTwwXNhz6t+9ajIwUb5Wg1X7OztJnZU2Qp4c7kICOM6oQZ\n3CpQzrSSPYnXX3lE3ctlJN2gSs1J1nueLVW01r7UD6Z8yXmGJcAvJxoCpRDy\nROu/z9+2p7Fv+dlFlv1Wawk+WkT7mZjPFbNhupileYefJ1unkwI1PD8PAHty\n+YVn\r\n=ykdI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"e67d4bd2b1e7fc11408f0189142c5366b55a0467","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest --testPathIgnorePatterns='DataUnion' test/integration","test-integration-flakey":"jest test/integration/DataUnionEndpoints.test.js"},"_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.10","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.20.1","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.3.3"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","buffer":"^6.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.5_1611024152290_0.6361315675958734","host":"s3://npm-registry-packages"}},"4.1.6":{"name":"streamr-client","version":"4.1.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@4.1.6","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a74465d6408589b838be2ed764a070f6a4225b2e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-4.1.6.tgz","fileCount":107,"integrity":"sha512-UnZoDDBboiOjFK/q5JyHsGSOs0edyOnAeI5bUljU7XlMnKmIufOJ3mHOujP+ylAzjB8CmOhsEEHTpY1uSPd/rg==","signatures":[{"sig":"MEUCIELlQVJF4sJt6fgAcnPezaYI4vGn1Ip2pCs8dRmxkDzgAiEA7k6EfZhj6wi4yvuHKS3cQI3K/kYyv4n8uYt68X19Fgs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10830702,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCKqhCRA9TVsSAnZWagAAaqMP/iG8uEatA2nvebWeGWZD\nk8gTlETqbS0P31K6QWg+0sdp7B8gIt5f+LpRus7xd4jp5EsQlLjWN7gEPlkE\nUGp+tFZxYkk1iGH4a6FETr1menQdV9fQAuPgqYowBM25h99J6s/5TJ+KyQub\nDg81eAYnG+S1g9arPyrMjlDjUfEWqNq6UNlXehLkuCXNktxLthwF3XQxhPbb\n5KVcnKyTgF9oluSRrmj42yjVsCr8uHoYm3bYq4yZ5jw1tNTO6i4NFJmkuQlD\nWN2Z7xxfDsJ+PZ9PuYhoE7vvCAbAU0koJEZNT/Z9zKaSos+vuCLUmMzp7tyK\nw1qcDYxXXSkdAKdftWtGfvkb8z7Zy1lMa6ot1yj8Rpwx9VBCgzrvgOTxmqo6\nsR8z0qgZ1I08FfPglD6ysshhwI3X0fmlGs3gDbDchllix0CVVzcAyzD154wl\nmd3iEkMoiH7+e9zwkWrlJm3YAqL46rvU26dnAjWga81pRwpQg8/juCt8YF52\ncSOBMfT3NbRGR0GN7JQH1iXk4gOq6WFC9dkzzaX9EI9+BR7za8qWDrELhqvu\nF8pC28YZs59l0SLXHplTkiPndEJNOUqrUM+P8VCbV0ihBoSSXNicdTr4jdks\noFKhD6iefajImMRB1X7pI+LPRlMQk73N5rGedCHkaLtbi9oyvb2JZnw/DqFC\nI9I2\r\n=No8R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"e8579b1c90ebf27b363a2bbec69ea4fd6389b86a","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint .","prepack":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","install-example":"cd examples/webpack && npm ci","test-integration":"jest --testPathIgnorePatterns='DataUnion' test/integration","test-integration-flakey":"jest test/integration/DataUnionEndpoints.test.js"},"_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"12.20.0","dependencies":{"qs":"^6.9.4","ws":"^7.3.1","once":"^1.4.0","uuid":"^8.3.0","debug":"^4.1.1","ethers":"^5.0.12","node-fetch":"^2.6.1","receptacle":"^1.3.2","randomstring":"^1.1.5","eventemitter3":"^4.0.7","@babel/runtime":"^7.11.2","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","node-webcrypto-ossl":"^2.1.1","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^5.3.3"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.4.2","sinon":"^9.0.3","buffer":"^6.0.3","eslint":"^7.8.1","core-js":"^3.6.5","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.11.6","nightwatch":"^1.4.1","@babel/core":"^7.11.6","geckodriver":"^1.20.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.1.3","@babel/preset-env":"^7.11.5","streamr-test-utils":"^1.0.4","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.1.0","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.10.3","@babel/plugin-transform-runtime":"^7.11.5","babel-plugin-add-module-exports":"^1.0.2","@babel/plugin-proposal-class-properties":"^7.10.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_4.1.6_1611180704876_0.6612708592007344","host":"s3://npm-registry-packages"}},"5.0.0-beta.3":{"name":"streamr-client","version":"5.0.0-beta.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9a80c7fb703c3078bb71c90c4a8bdb0e49f0ddd6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.3.tgz","fileCount":128,"integrity":"sha512-6O7sFqHQwK2kxMpuEvwhTkjPJ6ndRGyJv4xkSI3c6DoNpsVR8inLzxVVzuLYxJx98k1j0jaKc2YR4i+5ZTkm2Q==","signatures":[{"sig":"MEUCIDpmgNU+GsxEs1ScKxQo3HWNSXB8iJPBrpKAW6++RR1NAiEA2LDHyU36GrHM3kgsAFMZgdw7C++H5ce4nntuHsubt+U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17780302,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCKvNCRA9TVsSAnZWagAAidkP/1+8yn+z9kz9F+JYLHv4\nCUMsgdxsC+anMkz5hwgW0R0ssvwMTaKgpcRMaRkIvtDtnHyLwPRXMt5ugQdw\nSghCcFaU3KJv8M3xi2OYojIQoBMNG1yE5RLgozJvlMj1mZ7wlk/y+dkms/HS\nlFLHKGy/8P0+mrYHtrO9CimY4Vx0XvMXJSVHqjeD9QIhIIn5OL/NTe/Vba+B\n8RVQ4ZP79FsHAsNtlWcjrUUdvGQiVilYAHxJmlYv+JI4rP57PojzatqiFRyC\noLFYcg5Up35lneDE+nqK23CVYxcfPul89L+b/p22VDPQad9Qi8k8flkary2e\nn7JxN1eLEhubhE0b78ekFNckBaldZ8k52d7N0Y6bb1dIHMtePXxdy1gWN3A1\n8oH8EP5wN0o5D6HbFVTqPgUu4y/hW+HdPbSrvGQb8ZsEvtPuqJl72tfVHhLt\nI89Q6fAT0hLkMnUAPQDeEnF1jMwL3K/3FjJyDru3fCcUVEsQgBL6EPonkmTO\nE2mfNpBJyik+34pgLoJWJWBdR5Jf+IBkuBUTqkCS+bMO7e45i4L6j4dt+IwV\nkwlS5LWwhMyYNGr5NCocb08kybyIqEqvfJxs5sDbnUWJYHXz41P4GOtBRIvv\nO7p6v/sW0XpkLQlqpd29FjsTLru5V6uG2d7/QVQzR5SpwJBc6xBxoSNan0kS\n0VAP\r\n=9X4y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n- Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n- Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n- Dec 31st 2020: Support for API keys will end.\n- Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n#### Creating a StreamrClient instance\n\n```javascript\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```javascript\nconst StreamrClient = require('streamr-client')\n```\n\n#### Subscribing to real-time events in a stream\n\n```javascript\nconst sub = client.subscribe(\n    {\n        stream: 'streamId',\n        partition: 0,           // Optional, defaults to zero. Use for partitioned streams to select partition.\n        // optional resend options here\n    },\n    (message, metadata) => {\n        // This is the message handler which gets called for every incoming message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\n#### Resending historical data\n\n```javascript\nconst sub = await client.resend(\n    {\n        stream: 'streamId',\n        resend: {\n            last: 5,\n        },\n    },\n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n#### Programmatically creating a stream\n\n```javascript\nclient.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\n    .then((stream) => {\n        console.log(`Stream ${stream.id} has been created!`)\n        // Do something with the stream, for example call stream.publish(message)\n    })\n```\n\n#### Publishing data points to a stream\n\n```javascript\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nclient.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nclient.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nclient.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nclient.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nclient.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nclient.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nstream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                   | Description                                                  |\n| :------------------------ | :------------------------------- | :------------------------------------------------------------ |\n| url                      | wss://streamr.network/api/v1/ws | Address of the Streamr websocket endpoint to connect to.     |\n| restUrl                  | https://streamr.network/api/v1  | Base URL of the Streamr REST API.                            |\n| auth                     | {}                              | Object that can contain different information to authenticate. More details below. |\n| publishWithSignature     | 'auto'                          | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set. |\n| verifySignatures         | 'auto'                          | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                            | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required. |\n| autoDisconnect           | true                            | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`. |\n| orderMessages            | true                            | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check. |\n| maxPublishQueueSize      | 10000                           | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr. |\n| publisherGroupKeys       | {}                              | Object defining the group key as a hex string used to encrypt for each stream id. |\n| publisherStoreKeyHistory | true                            | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests. |\n| subscriberGroupKeys      | {}                              | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined. |\n| keyExchange              | {}                              | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required. |\n\n## Authentication options\n\n**Authenticating with an API key has been deprecated.** \n\n**Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```javascript\nnew StreamrClient({\n    auth: {\n        provider: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```javascript\nnew StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                  |\n| :------------- | :------------------------------------------------------------ |\n| payload       | A JS object containing the message payload itself            |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n## StreamrClient object\n\n#### Connecting\n\n| Name                 | Description                                                  |\n| :-------------------- | :------------------------------------------------------------ |\n| connect()            | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`. Returns a Promise. Rejects if already connected or connecting. |\n| disconnect()         | Disconnects from the server, clearing all subscriptions. Returns a Promise.  Rejects if already disconnected or disconnecting. |\n| pause()              | Disconnects from the server without clearing subscriptions.  |\n| ensureConnected()    | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection. |\n| ensureDisconnected() | Safely disconnects if not disconnected. Returns a promise. Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n\n#### Managing subscriptions\n\n| Name                         | Description                                                  |\n| :---------------------------- | :------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`.                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`.             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.            |\n\n#### Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                  |\n| :--------------------------------------------------- | :------------------------------------------------------------ |\n| getStream(streamId)                                 | Fetches a stream object from the API.                        |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com). |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.       |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found. |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                 |\n\n#### Listening to state changes of the client\n\non(eventName, function) | Binds a `function` to an event called `eventName`\nonce(eventName, function) | Binds a `function` to an event called `eventName`. It gets called once and then removed.\nremoveListener(eventName, function) | Unbinds the `function` from events called `eventName`\n\n## Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                  |\n| :----------------------------------------- | :------------------------------------------------------------ |\n| update()                                  | Updates the properties of this stream object by sending them to the API. |\n| delete()                                  | Deletes this stream.                                         |\n| getPermissions()                          | Returns the list of permissions for this stream.             |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above. |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                 |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream. |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                      |\n\n## Subscription options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                  |\n| :--------- | :------------------------------------------------------------ |\n| stream    | Stream id to subscribe to                                    |\n| partition | Partition number to subscribe to. Defaults to partition 0.   |\n| resend    | Object defining the resend options. Below are examples of its contents. |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```javascript\n// Resend N most recent messages\nresend: {\n    last: 10,\n}\n\n// Resend from a specific message reference up to the newest message\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    }\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n\n// Resend a limited range of messages\nresend: {\n    from: {\n        timestamp: 12345,\n        sequenceNumber: 0, // optional\n    },\n    to: {\n        timestamp: 54321,\n        sequenceNumber: 0, // optional\n    },\n    publisher: 'publisherId', // optional\n    msgChainId: 'msgChainId', // optional\n}\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```javascript\nconst sub = client.subscribe(...)\nsub.on('initial_resend_done', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Data Unions\n\nThis library provides functions for working with Data Unions.\n\nTODO: check all this documentation before merging/publishing, probably some of it is out of date (DU1 era)\n\nData union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function.\n\n| Property      | Default               | Description                                                  |\n| :------------ | :-------------------- | :------------------------------------------------------------ |\n| wallet        | given in auth         | ethers.js Wallet object to use to sign and send withdraw transaction |\n| provider      | mainnet               | ethers.js Provider to use if wallet wasn't provided          |\n| confirmations | `1`                   | Number of blocks to wait after the withdraw transaction is mined |\n| gasPrice      | ethers.js supplied    | Probably uses the network estimate\n| dataUnion     | -                     | Address or contract object of the data union that is the target of the operation\n| tokenAddress  | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU\n| minimumWithdrawTokenWei    | 1000000  | Threshold value set in AMB configs, smallest token amount that can pass over the bridge\n| sidechainTokenAddress      |  TODO    | sidechain token address\n| factoryMainnetAddress      |  TODO    | Data Union factory that creates a new Data Union\n| sidechainAmbAddress        |  TODO    | Arbitrary Message-passing Bridge (AMB), see [Tokenbridge github page](https://github.com/poanetwork/tokenbridge)\n| payForSignatureTransport   | `true`   | Someone must pay for transporting the withdraw tx to mainnet, either us or bridge operator\n\n#### Admin functions\n\n| Name                                                      | Returns               | Description                                                |\n| :-------------------------------------------------------- | :-------------------- | :--------------------------------------------------------- |\n| deployDataUnion(options)                                  | Dataunion contract    | Deploy a new Data Union                                    |\n| createSecret(dataUnionContractAddress, secret[, name])    |                       | Create a secret for a Data Union                           |\n| addMembers(memberAddressList, options)                    | Transaction receipt   | Add members                                                |\n| kick(memberAddressList, options)                          | Transaction receipt   | Kick members out from Data Union                           |\n| withdrawMember(memberAddress, options) |||\n| withdrawToSigned(memberAddress, recipientAddress, signature, options) |||\n| setAdminFee(newFeeFraction, options)                      | Transaction receipt   | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```javascript\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n#### Member functions\n\n| Name                                                              | Returns       | Description                                                   |\n| :---------------------------------------------------------------- | :------------ | :------------------------------------------------------------ |\n| joinDataUnion(options)                                            | JoinRequest   | Join a Data Union                                             |\n| hasJoined([memberAddress], options)                               |  -            | Wait until member has been accepted                           |\n| withdraw(options)                                                 | Transaction receipt   | Withdraw funds from Data Union                        |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options)   | Transaction receipt   | Donate/move your earnings to recipientAddress instead of your memberAddress   |\n| signWithdrawTo(recipientAddress, options)                         | Signature (string)    | Signature that can be used to withdraw tokens to given recipientAddress       |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei, options)   | Signature (string)    | Signature that can be used to withdraw tokens to given recipientAddress       |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```javascript\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\nconst signature = await client.signWithdrawTo(recipientAddress)\n```\n\n#### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                      | Returns                                 | Description                 |\n| :-------------------------------------------------------- | :-------------------------------------- | :-------------------------- |\n| getMemberStats(dataUnionContractAddress[, memberAddress]) | {earnings, proof, ...}                  | Get member's stats          |\n| getDataUnionStats(dataUnionContractAddress)               | {activeMemberCount, totalEarnings, ...} | Get Data Union's statistics |\n| ~~getMembers(dataUnionContractAddress)~~                  | | NOT available in DU2 at the moment    |\n| getAdminFee(options)                                      | `Number` between 0.0 and 1.0 (inclusive)| Admin's cut from revenues   |\n| getAdminAddress(options)                                  | Ethereum address | Data union admin's address   |\n| getDataUnionStats(options)                                | Stats object                            | Various metrics from the smart contract |\n| getMemberStats([memberAddress], options)                  | Member stats object                     | Various metrics from the smart contract |\n| getMemberBalance([memberAddress], options)                | `BigNumber` withdrawable DATA tokens in the DU | |\n| getTokenBalance(address, options)                         | `BigNumber`                             | Mainnet DATA token balance |\n| getDataUnionVersion(contractAddress)                      | `0`, `1` or `2`                         | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```javascript\nconst client = new StreamrClient({\n    dataUnion,\n})\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                  |\n| :--------------------------------------- | :------------------------------------------------------------ |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\n#### Binding to events\n\nThe client and the subscriptions can fire events as detailed below. You can bind to them using `on`:\n\n```javascript\n    // The StreamrClient emits various events\n\tclient.on('connected', () => {\n\t    console.log('Yeah, we are connected now!')\n\t})\n\n    // So does the Subscription object\n\tconst sub = client.subscribe(...)\n\tsub.on('subscribed', () => {\n\t    console.log(`Subscribed to ${sub.streamId}`)\n\t})\n```\n\n#### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                           |\n| :------------ | :----------------- | :----------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected). |\n| disconnected |                   | Fired when the client has disconnected (or paused).   |\n\n#### Events on the Subscription object\n\n| Name         | Handler Arguments                                            | Description                                                  |\n| :------------ | :------------------------------------------------------------ | :------------------------------------------------------------ |\n| subscribed   |                                                              | Fired when a subscription request is acknowledged by the server. |\n| unsubscribed |                                                              | Fired when an unsubscription is acknowledged by the server.  |\n| resending    | [ResendResponseResending](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resending/ResendResponseResendingV1.js) | Fired when the subscription starts resending. Followed by the `resent` event to mark completion of the resend after resent messages have been processed by the message handler function. |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending. |\n| no_resend    | [ResendResponseNoResend](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_no_resend/ResendResponseNoResendV1.js) | This will occur instead of the `resending` - `resent` sequence in case there were no messages to resend. |\n| error        | Error object                                                 | Reports errors, for example problems with message content    |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```javascript\nclient.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n}).then(stream => {\n    console.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n})\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a *partition key*, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```javascript\nclient.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nstream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```javascript\nclient.subscribe(\n    {\n        stream: 'my-stream-id',\n        partition: 4, // defaults to 0\n    },\n    (payload) => {\n        console.log(`Got message ${JSON.stringify(payload)}`)\n    },\n)\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```javascript\nconst handler = (payload, streamMessage) => {\n    console.log(`Got message ${JSON.stringify(payload)} from partition ${streamMessage.getStreamPartition()}`)\n}\n\n[2,3,4].forEach(partition => {\n    client.subscribe(\n        {\n            stream: 'my-stream-id',\n            partition: partition,\n        },\n        handler,\n    )\n})\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, include `debug.js` and set `localStorage.debug = 'StreamrClient'`\n\n\n## Publishing\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n#### Publishing `latest`:\n\n1. Update version with either `npm version [patch|minor|major]`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n\n#### Publishing `beta`:\n\n1. Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n   https://semver.org/. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n2. `git push --follow-tags`\n3. Wait for Github Actions to run tests\n4. If tests passed, Github Actions will publish the new version to NPM\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"a8db7683eb56a9f01f2f9ff8ccae74d84bd2e842","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ . ","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey/*","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --testTimeout=15000 test/integration/DataUnionEndpoints"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/sha2":"^5.0.3","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.3","@ethersproject/wallet":"^5.0.6","node-abort-controller":"^1.1.0","@ethersproject/address":"^5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.1.2","@ethersproject/bignumber":"^5.0.6","@ethersproject/contracts":"^5.0.3","@ethersproject/keccak256":"^5.0.6","@ethersproject/providers":"^5.0.14","@ethersproject/transactions":"^5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","buffer":"^6.0.3","eslint":"^7.14.0","ethers":"^5.0.21","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","async-mutex":"^0.2.4","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.2.0","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.3_1611181004630_0.7936086893653289","host":"s3://npm-registry-packages"}},"5.0.0-beta.4":{"name":"streamr-client","version":"5.0.0-beta.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"cbcebb3133272c2e8c1c6b90daef6607a178f2ae","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.4.tgz","fileCount":128,"integrity":"sha512-PR4pPW1ZkmJL3XNu58AHaM4bHGNqRpuH5Rcbp+7fsW2+3YF8Yx62OXEhuLA/CIn6s422DbRhy0W9oYT1200R/Q==","signatures":[{"sig":"MEQCICluGahYXXP1X6Rcs4nBWfExflU2DXGTux4f8ku8uJelAiB6JQ0q2TK2CmqNEEYbv9Lt1ctES0KasPTE7JpjCfFtCQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17791408,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCwfNCRA9TVsSAnZWagAAIFgP/0ISTTUf3xj4blqyBsDh\nl6nXvuGHRKb1ryWYPAqYAA6bWmHWCoIiDqD64sQ3jyFzunrESM1NCn9TB4RT\nZN0geLsGhTG/ikF8JRkKO8+p17CIuAGW904OCioJImVDsDBusAd/loP5HUTl\nduL3uyG7oF4V4Zo3DFyZQMnIzVxVb6pDEmmzIMjxeJpvK+COHz3yD64jax1g\nh8zXGHiU3/yN1JwnYvRqBUAn8T8OYVv9ZeRsKWZxV7uglgKcr9HahQErjZ57\nOQw1XaD3FwUVtbY0KEEmDNTvqRgsvsjr7XiUXQRbPapHYshgNGpq9hol97Un\noGRhFaGbBHKMIct59+HXoIpYm7Sa51DA0UzTiqtSq1fsaSNry18SguPaNo/X\n9FbGU+ylP40R9vgMJNb7OU3yg+rOAuo+bqnzoC+kqUE1SdJt4a7iONwwzUel\nzYjLZgPUyqEQeFZqdTimVreFQMU0piR7bxX4lVtvJMeciEJAK/CSLzD6Wg2m\nTIS2D9GIXiia01PamIu4AUFrvIWuYqJUJE7aNcPk6C2FaDzIB2UdQOMbLhvj\n17+Rjf95lipHcYF8nR5dFI+Nc24wB6Tx5aH+4nzbVl6z8Ew02AeJzqye7oH/\n+bd7RJxibaptELqGFjr09a/c9/wHI/W6I8jM+EEXKuejV05Ivjubbu5w1rhb\nGo7F\r\n=5G1/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n\n* Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n* Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n* Dec 31st 2020: Support for API keys will end.\n* Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [Connecting](#connecting) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Partitioning](#partitioning) · [Logging](#logging) · [For Developers](#for-developers)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```js\nconst StreamrClient = require('streamr-client')\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.provider`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated.**\n\nNote: **Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions.\n\nTODO: check all this documentation before merging/publishing, probably some of it is out of date (DU1 era)\n\nData union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function.\n\n| Property                 | Default                                                | Description                                                                                                      |\n| :----------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| wallet                   | given in auth                                          | ethers.js Wallet object to use to sign and send withdraw transaction                                             |\n| provider                 | mainnet                                                | ethers.js Provider to use if wallet wasn't provided                                                              |\n| confirmations            | `1`                                                    | Number of blocks to wait after the withdraw transaction is mined                                                 |\n| gasPrice                 | ethers.js supplied                                     | Probably uses the network estimate                                                                               |\n| dataUnion                | -                                                      | Address or contract object of the data union that is the target of the operation                                 |\n| tokenAddress             | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU                                                                                             |\n| minimumWithdrawTokenWei  | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| sidechainTokenAddress    | TODO                                                   | sidechain token address                                                                                          |\n| factoryMainnetAddress    | TODO                                                   | Data Union factory that creates a new Data Union                                                                 |\n| sidechainAmbAddress      | TODO                                                   | Arbitrary Message-passing Bridge (AMB), see [Tokenbridge github page](https://github.com/poanetwork/tokenbridge) |\n| payForSignatureTransport | `true`                                                 | Someone must pay for transporting the withdraw tx to mainnet, either us or bridge operator                       |\n\n### Admin Functions\n\n| Name                                                                  | Returns             | Description                                                    |\n| :-------------------------------------------------------------------- | :------------------ | :------------------------------------------------------------- |\n| deployDataUnion(options)                                              | Dataunion contract  | Deploy a new Data Union                                        |\n| createSecret(dataUnionContractAddress, secret\\[, name])               |                     | Create a secret for a Data Union                               |\n| addMembers(memberAddressList, options)                                | Transaction receipt | Add members                                                    |\n| kick(memberAddressList, options)                                      | Transaction receipt | Kick members out from Data Union                               |\n| withdrawMember(memberAddress, options)                                |                     |                                                                |\n| withdrawToSigned(memberAddress, recipientAddress, signature, options) |                     |                                                                |\n| setAdminFee(newFeeFraction, options)                                  | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n### Member functions\n\n| Name                                                            | Returns             | Description                                                                 |\n| :-------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| joinDataUnion(options)                                          | JoinRequest         | Join a Data Union                                                           |\n| hasJoined(\\[memberAddress], options)                            | -                   | Wait until member has been accepted                                         |\n| withdraw(options)                                               | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawTo(recipientAddress, options)                       | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei, options) | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\n\nconst signature = await client.signWithdrawTo(recipientAddress)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getMemberStats(dataUnionContractAddress\\[, memberAddress]) | {earnings, proof, ...}                         | Get member's stats                      |\n| getDataUnionStats(dataUnionContractAddress)                | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| ~~getMembers(dataUnionContractAddress)~~                   |                                                | NOT available in DU2 at the moment      |\n| getAdminFee(options)                                       | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress(options)                                   | Ethereum address                               | Data union admin's address              |\n| getDataUnionStats(options)                                 | Stats object                                   | Various metrics from the smart contract |\n| getMemberStats(\\[memberAddress], options)                  | Member stats object                            | Various metrics from the smart contract |\n| getMemberBalance(\\[memberAddress], options)                | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getTokenBalance(address, options)                          | `BigNumber`                                    | Mainnet DATA token balance              |\n| getDataUnionVersion(contractAddress)                       | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nconst client = new StreamrClient({\n    dataUnion,\n})\n\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                                                                                                                                                                                                                       |\n| :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"2e908093d859a33ed9de5e378c9fd3abdb6953e9","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ . ","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey/*","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --testTimeout=15000 test/integration/DataUnionEndpoints"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/sha2":"^5.0.3","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.3","@ethersproject/wallet":"^5.0.6","node-abort-controller":"^1.1.0","@ethersproject/address":"^5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.1.2","@ethersproject/bignumber":"^5.0.6","@ethersproject/contracts":"^5.0.3","@ethersproject/keccak256":"^5.0.6","@ethersproject/providers":"^5.0.14","@ethersproject/transactions":"^5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","buffer":"^6.0.3","eslint":"^7.14.0","ethers":"^5.0.21","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","async-mutex":"^0.2.4","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.2.0","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.4_1611335628752_0.97370026438907","host":"s3://npm-registry-packages"}},"5.0.0-beta.5":{"name":"streamr-client","version":"5.0.0-beta.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0a6e5c72fdbd4b0ac5be7c3d8a19be0c646c82b4","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.5.tgz","fileCount":128,"integrity":"sha512-/6Kchw0Ag2Qjc4sqE1HEZcg28OB2frNIBg/pkTyOvlulxbRVTe3qc9aWsPcYtwvoxoNnX4zKFFoHcJex0dKhrg==","signatures":[{"sig":"MEUCIQCH8XAlrgdA3+uun1ENGhToYnln8NcNS8oyLkHSmZiF6wIgJgirDGqlZOuzMLMiJn8Px/QWuzIH7YLriiCOVH0jk1M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17830020,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgENLaCRA9TVsSAnZWagAAkgMQAJUOCoUeumkIf9iKQb6C\ne/J1/5sdbfzEqvPSNPvQCc4lJL6o5bbYamKf4raqOE7mkDf8xEPmxvfxk4dS\noNkk0vfW46mpl+whqk20/kUOTaIv8uaSHeAFlSJzz21nWPF49SFwURNLXqis\nbYITPLpSIhvqreev8R1zeQ3cQKWzpf+70X6kY9znXmAwg6G9lyKmNk0mmDjr\n55JC9Vu2S3XDzRt24ymiueJL/HRtWzc3AYyniVJACniJ7C2hEDGfXJbhq/3G\n+7ShUB/qESRm+uYwgE0KGCnoOuxO/H9/YL2w2j7j5uSxdb9KUxDKdVq+LGcL\nCyyUvazFff+/59B6PzLNbCAW2kBaYs82H1bq9n8sTlGqk0c9zKb/7dsESpLI\nvPqWXSo/DexVF5bxaNwELMHKvAK0UhhBBWF6R004Tlx22xecbbvuRQAiPlRU\niFEzJ+1vaqtc+YWWCAC9cRJP0ATbZT7UiCBmup0YG7OD0gg7chEw6Mpti7mR\nJUJIociLCAR3nnIuAI2KdLp4CKRsu6Wi6OAFk0pO55hY7EpnbkgU5buR8nMR\n66lZD9ei6N8a7P840OX1WOMQCQfChtcFpxLRq0tLp/++tWp30g4gPIohWK1C\nUpfjO94QeI0yUsRCMrz/4qXbk2s4vgdnndOnIBGH020XC60+qoCKn6aX42vr\nwSsG\r\n=sHpg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n\n* Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n* Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n* Dec 31st 2020: Support for API keys will end.\n* Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [Connecting](#connecting) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Partitioning](#partitioning) · [Logging](#logging) · [For Developers](#for-developers)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```js\nconst StreamrClient = require('streamr-client')\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated.**\n\nNote: **Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions.\n\nTODO: check all this documentation before merging/publishing, probably some of it is out of date (DU1 era)\n\nData union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function.\n\n| Property                 | Default                                                | Description                                                                                                      |\n| :----------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| wallet                   | given in auth                                          | ethers.js Wallet object to use to sign and send withdraw transaction                                             |\n| provider                 | mainnet                                                | ethers.js Provider to use if wallet wasn't provided                                                              |\n| confirmations            | `1`                                                    | Number of blocks to wait after the withdraw transaction is mined                                                 |\n| gasPrice                 | ethers.js supplied                                     | Probably uses the network estimate                                                                               |\n| dataUnion                | -                                                      | Address or contract object of the data union that is the target of the operation                                 |\n| tokenAddress             | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU                                                                                             |\n| minimumWithdrawTokenWei  | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| sidechainTokenAddress    | TODO                                                   | sidechain token address                                                                                          |\n| factoryMainnetAddress    | TODO                                                   | Data Union factory that creates a new Data Union                                                                 |\n| sidechainAmbAddress      | TODO                                                   | Arbitrary Message-passing Bridge (AMB), see [Tokenbridge github page](https://github.com/poanetwork/tokenbridge) |\n| payForSignatureTransport | `true`                                                 | Someone must pay for transporting the withdraw tx to mainnet, either us or bridge operator                       |\n\n### Admin Functions\n\n| Name                                                                  | Returns             | Description                                                    |\n| :-------------------------------------------------------------------- | :------------------ | :------------------------------------------------------------- |\n| deployDataUnion(options)                                              | Dataunion contract  | Deploy a new Data Union                                        |\n| createSecret(dataUnionContractAddress, secret\\[, name])               |                     | Create a secret for a Data Union                               |\n| addMembers(memberAddressList, options)                                | Transaction receipt | Add members                                                    |\n| kick(memberAddressList, options)                                      | Transaction receipt | Kick members out from Data Union                               |\n| withdrawMember(memberAddress, options)                                |                     |                                                                |\n| withdrawToSigned(memberAddress, recipientAddress, signature, options) |                     |                                                                |\n| setAdminFee(newFeeFraction, options)                                  | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n### Member functions\n\n| Name                                                            | Returns             | Description                                                                 |\n| :-------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| joinDataUnion(options)                                          | JoinRequest         | Join a Data Union                                                           |\n| hasJoined(\\[memberAddress], options)                            | -                   | Wait until member has been accepted                                         |\n| withdraw(options)                                               | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawTo(recipientAddress, options)                       | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei, options) | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\n\nconst signature = await client.signWithdrawTo(recipientAddress)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getMemberStats(dataUnionContractAddress\\[, memberAddress]) | {earnings, proof, ...}                         | Get member's stats                      |\n| getDataUnionStats(dataUnionContractAddress)                | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| ~~getMembers(dataUnionContractAddress)~~                   |                                                | NOT available in DU2 at the moment      |\n| getAdminFee(options)                                       | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress(options)                                   | Ethereum address                               | Data union admin's address              |\n| getDataUnionStats(options)                                 | Stats object                                   | Various metrics from the smart contract |\n| getMemberStats(\\[memberAddress], options)                  | Member stats object                            | Various metrics from the smart contract |\n| getMemberBalance(\\[memberAddress], options)                | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getTokenBalance(address, options)                          | `BigNumber`                                    | Mainnet DATA token balance              |\n| getDataUnionVersion(contractAddress)                       | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nconst client = new StreamrClient({\n    dataUnion,\n})\n\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                                                                                                                                                                                                                       |\n| :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"b589499bc230622aa8e3bb2951875ad3b849bb6a","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ . ","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey/*","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --testTimeout=15000 test/integration/DataUnionEndpoints"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.10","description":"JavaScript client library for Streamr","directories":{"test":"test","example":"examples"},"_nodeVersion":"14.15.4","dependencies":{"qs":"^6.9.4","ws":"^7.4.0","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.1","debug":"^4.3.1","p-limit":"^3.0.2","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.2","node-fetch":"^2.6.1","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.3","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/sha2":"^5.0.3","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.3","@ethersproject/wallet":"^5.0.6","node-abort-controller":"^1.1.0","@ethersproject/address":"^5.0.3","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.1.2","@ethersproject/bignumber":"^5.0.6","@ethersproject/contracts":"^5.0.3","@ethersproject/keccak256":"^5.0.6","@ethersproject/providers":"^5.0.14","@ethersproject/transactions":"^5.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.1","buffer":"^6.0.3","eslint":"^7.14.0","ethers":"^5.0.21","core-js":"^3.7.0","express":"^4.17.1","webpack":"^4.44.1","benchmark":"^2.1.4","@babel/cli":"^7.12.7","nightwatch":"^1.5.1","@babel/core":"^7.12.7","async-mutex":"^0.2.4","geckodriver":"^1.21.0","jest-circus":"^26.6.3","webpack-cli":"^4.2.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.1","chromedriver":"^86.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.4.0","@babel/preset-env":"^7.12.7","streamr-test-utils":"^1.1.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.2.0","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.1","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.2","utf-8-validate":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.5_1611715289602_0.27609980616113794","host":"s3://npm-registry-packages"}},"5.0.0-beta.6":{"name":"streamr-client","version":"5.0.0-beta.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.6","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b07eeb8dca55ddacbb7acd53f722e8278f19c010","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.6.tgz","fileCount":131,"integrity":"sha512-4c7L5X/Z4Aj+AAbKNdIVOVIHhL7lwLj72IeAR/lmA8l446sQ8iikUWUDvGSgjOSahasCSUFKMd9FLN3RyuZJtQ==","signatures":[{"sig":"MEYCIQDw7Hl0N14iFkzP7v5GGa4t9BIKCeyviwBoHY164P1vMQIhALVnovlDmfAb4RN4BUZ2ERIUrnzWjAdUNGEhdKhVuWf/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17858745,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJCZyCRA9TVsSAnZWagAA2+cP/1f29BjNzGVlhdDMyEH0\nmyCazPLEiJCbAWyXIekcFq6dJPzrunxiqwIWV7uu/fvxhPCwN6JTgBFhzM54\nT1LxXAY7FyuTcdM846+vVh/Vn1Mh3XlV/irKY1HTwBaMEhCT8wCiVtVZP4He\nTtB2ayhVMfsta5FSfsr27xpKAAsXolNw8tb9taGTP16/2QnXscwXzTwnUZzD\njWRkcsiVB1CcfuL6iU14pomn4SbY8up6PFMq3MsNxHOeUWjc5L26GOyaOJaG\n/O6T41U+tHamecN7EjCs4SAEZfEjVQiOTKjlDs5uyBz2QvQ3/XqU/rEwQFAf\nTgTg1jrWKmm7QVsv4rO2XTmLuRqAfVY2DSaNcsSfFcwt8LBruvF8WS0eljfL\n3Z3cyoNMQtm+Wh7NfUXYhur037wBeGss3PAyPfpC7sUV5N1LJMSDkx67whbZ\nJ2Z7zuYgWTjcgFsq6Nyvc180nZ1uMa+xK19p21u6SAHGSxGEvjs8AewkPcVT\nOzGVSe3eQnCf+6UH6NE3hVcY3SGrKsaMONVhl/egUCLNqEoy6Z9qU9xpciM3\nMBYz49iPCK08jTuz/MhcdGh/ouOg+zgWvhRnZL3QbPCnLlo5Ex2JNFNYTdQJ\nlVtjh0Pb8Jx03oIhKOg4MM3JUdEDVYJMpXbr6I4+fBhUqxMobu7toL2kP2c6\nDFm4\r\n=j78x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n\n* Dec 31st 2020: Email/password login will be removed. **Connect your email account to an Ethereum address before the deadline!**\n* Dec 31st 2020: Stream storage becomes opt-in and freely choosable.\n* Dec 31st 2020: Support for API keys will end.\n* Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [Connecting](#connecting) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Partitioning](#partitioning) · [Logging](#logging) · [For Developers](#for-developers)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```js\nconst StreamrClient = require('streamr-client')\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated.**\n\nNote: **Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions.\n\nTODO: check all this documentation before merging/publishing, probably some of it is out of date (DU1 era)\n\nData union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function.\n\n| Property                 | Default                                                | Description                                                                                                      |\n| :----------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| wallet                   | given in auth                                          | ethers.js Wallet object to use to sign and send withdraw transaction                                             |\n| provider                 | mainnet                                                | ethers.js Provider to use if wallet wasn't provided                                                              |\n| confirmations            | `1`                                                    | Number of blocks to wait after the withdraw transaction is mined                                                 |\n| gasPrice                 | ethers.js supplied                                     | Probably uses the network estimate                                                                               |\n| dataUnion                | -                                                      | Address or contract object of the data union that is the target of the operation                                 |\n| tokenAddress             | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU                                                                                             |\n| minimumWithdrawTokenWei  | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| sidechainTokenAddress    | TODO                                                   | sidechain token address                                                                                          |\n| factoryMainnetAddress    | TODO                                                   | Data Union factory that creates a new Data Union                                                                 |\n| sidechainAmbAddress      | TODO                                                   | Arbitrary Message-passing Bridge (AMB), see [Tokenbridge github page](https://github.com/poanetwork/tokenbridge) |\n| payForSignatureTransport | `true`                                                 | Someone must pay for transporting the withdraw tx to mainnet, either us or bridge operator                       |\n\n### Admin Functions\n\n| Name                                                                  | Returns             | Description                                                    |\n| :-------------------------------------------------------------------- | :------------------ | :------------------------------------------------------------- |\n| deployDataUnion(options)                                              | Dataunion contract  | Deploy a new Data Union                                        |\n| createSecret(dataUnionContractAddress, secret\\[, name])               |                     | Create a secret for a Data Union                               |\n| addMembers(memberAddressList, options)                                | Transaction receipt | Add members                                                    |\n| kick(memberAddressList, options)                                      | Transaction receipt | Kick members out from Data Union                               |\n| withdrawMember(memberAddress, options)                                |                     |                                                                |\n| withdrawToSigned(memberAddress, recipientAddress, signature, options) |                     |                                                                |\n| setAdminFee(newFeeFraction, options)                                  | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n### Member functions\n\n| Name                                                            | Returns             | Description                                                                 |\n| :-------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| joinDataUnion(options)                                          | JoinRequest         | Join a Data Union                                                           |\n| hasJoined(\\[memberAddress], options)                            | -                   | Wait until member has been accepted                                         |\n| withdraw(options)                                               | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawTo(recipientAddress, dataUnionContractAddress, options) | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawTo(recipientAddress, options)                       | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei, options) | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\n\nconst signature = await client.signWithdrawTo(recipientAddress)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getMemberStats(dataUnionContractAddress\\[, memberAddress]) | {earnings, proof, ...}                         | Get member's stats                      |\n| getDataUnionStats(dataUnionContractAddress)                | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| ~~getMembers(dataUnionContractAddress)~~                   |                                                | NOT available in DU2 at the moment      |\n| getAdminFee(options)                                       | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress(options)                                   | Ethereum address                               | Data union admin's address              |\n| getDataUnionStats(options)                                 | Stats object                                   | Various metrics from the smart contract |\n| getMemberStats(\\[memberAddress], options)                  | Member stats object                            | Various metrics from the smart contract |\n| getMemberBalance(\\[memberAddress], options)                | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getTokenBalance(address, options)                          | `BigNumber`                                    | Mainnet DATA token balance              |\n| getDataUnionVersion(contractAddress)                       | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nconst client = new StreamrClient({\n    dataUnion,\n})\n\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                                                                                                                                                                                                                       |\n| :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"42221ed77d18706f4044bf02969726cbf3babc9f","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm dist/*; NODE_ENV=production webpack --mode=production --progress","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ . ","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey/*","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --testTimeout=15000 test/integration/DataUnionEndpoints"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{"test":"test","example":"examples"},"_nodeVersion":"14.15.4","dependencies":{"qs":"^6.9.6","ws":"^7.4.2","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.3","node-fetch":"^2.6.1","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.5","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/sha2":"^5.0.7","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.9","@ethersproject/wallet":"^5.0.10","node-abort-controller":"^1.1.0","@ethersproject/address":"^5.0.9","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^7.1.2","@ethersproject/bignumber":"^5.0.13","@ethersproject/contracts":"^5.0.9","@ethersproject/keccak256":"^5.0.7","@ethersproject/providers":"^5.0.19","@ethersproject/transactions":"^5.0.9"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.18.0","ethers":"^5.0.26","core-js":"^3.8.3","express":"^4.17.1","webpack":"^4.46.0","benchmark":"^2.1.4","@babel/cli":"^7.12.10","nightwatch":"^1.5.1","@babel/core":"^7.12.10","async-mutex":"^0.2.6","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.4.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@babel/preset-env":"^7.12.11","streamr-test-utils":"^1.3.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.4.0","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.10","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.6_1612981873535_0.8470581445962297","host":"s3://npm-registry-packages"}},"5.0.0-beta.7":{"name":"streamr-client","version":"5.0.0-beta.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.7","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b8ee2a3d05d8a015bf1e5c49bdb79dfe22a9ba97","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.7.tgz","fileCount":170,"integrity":"sha512-TdivlY/6HCVPEbvd0SqqBT0552JITsWNjfgPXXu3LGhR8/KKa2Hj8+T6iNOJhNtPdJMko9aToxaZAu9iX0cA5Q==","signatures":[{"sig":"MEUCIQCLN+3KjEBr4mMpQXA5TOQnr+loGbkr3uAMoPJi4Y246gIgc7dtOxKnGquCrhc0N03iID7/agKRSWOFycq8QAH+Uic=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15831811,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNW8mCRA9TVsSAnZWagAAVpgP/0F3e6+pFEju3N4Z4DZS\nV8ynmr2g1B+pZiuGqAkBw8f04NVY/ISHItLXPEbhrYWZGuwdnodRI9tE2npQ\njXeyD+NJS3EdPpsQx7ces1yFQo5vv1XRbdHsdR2eF3b9s2CfLs65C09CKBTm\nPCQgki9O9TH9DSta4BXL32J4XWNiuhnTYkUof+1vomJSCr/RhDpkZxED0gwx\nfVqfLSYFMbkilIO9XggoFiZzU6AhqzyuE5AblHoy+HejHpMxD4GuGoaIch3i\nVURmJEPkAiAzxIq3ZebCExG+y3uNCjRCAlXJ6aFgBKy/vCkdo2PMyTAuEtuW\nuSwOsRjkbeakxbRBekA+qt+Fdn6qbuaufwdnIljCCrgw/6Fa/X1U0VRVC7Ni\np5xsWIYbe2NzYE+1BvNXyfIR/f5INYfKwb8T7GTQAAZN09kpDI/6DKNvNCNo\n3zqJROZ41xC7Tt7yO4n5W8L5l+V7WNWcYalgMWvoQ8cSqLO3Gdv8o8WYeTPt\naaNcN3Z1HxlwkP7hOc4i0kBcoBrBNyYGKSsS0cFC5YnwCD41TnHO/tt1o/8F\nE4N1XKk3y/jWjo2aFlZoVTud/rxcGkVOq3QgtzHN3vzTcYvUiCuESbK3erQl\nGhLqF+DdqbKtKyOJrXFJWqYQQtb9F7qj6ll/9QuUchG1zWtRb9F8jezepMUp\n7y0/\r\n=j8+z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/streamr-client.nodejs.js","types":"dist/types/src/StreamrClient.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to require the library with:\n\n```js\nconst StreamrClient = require('streamr-client')\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated.**\n\nNote: **Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(properties)                            | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. To get a DataUnion instance, call `client.getDataUnion(address)`. To deploy a new DataUnion, call `deployDataUnion(options)`\n\nTODO: All `options`-parameters should be documented (see TypeScript interfaces for the definitions)\n\nThese DataUnion-specific options are used from `StreamrClient` options:\n| Property                 | Default                                                | Description                                                                                                      |\n| :----------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| tokenAddress             | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU                                                                                             |\n| factoryMainnetAddress    | TODO                                                   | Data Union factory that creates a new Data Union                                                                 |\n| minimumWithdrawTokenWei  | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n\n\n### Admin Functions\n\n| Name                                                                        | Returns             | Description                                                    |\n| :-------------------------------------------------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])                                                       | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList, \\[options])                                   | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList, \\[options])                                | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress, \\[options])                              |                     |                                                                |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature, \\[options]) |                     |                                                                |\n| setAdminFee(newFeeFraction)                                                 | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n### Member functions\n\n| Name                                                            | Returns             | Description                                                                 |\n| :-------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                 | JoinRequest         | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                         | boolean             |                                                                             |\n| withdrawAll(\\[options])                                         | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress, \\[options])                     | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                             | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)          | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\n\nconst signature = await client.signWithdrawAllTo(recipientAddress)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nconst client = new StreamrClient({\n    dataUnion,\n})\n\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                                                                                                                                                                                                                       |\n| :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n| getTokenBalance(address)                | `BigNumber`                                     | Mainnet DATA token balance                       |\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"dist/streamr-client.web.min.js","engines":{"node":">= 12"},"gitHead":"aaed908a20b8551070e8bf2835edd74d928d85f5","scripts":{"dev":"webpack --progress --colors --watch --mode=development","test":"jest --detectOpenHandles","build":"rm -rf dist; NODE_ENV=production webpack --mode=production --progress && npm run build:types","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","test-types":"tsc --noEmit --project ./tsconfig.test.json","build:types":"tsc --emitDeclarationOnly","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; jest --clearCache;","test-flakey":"jest --forceExit test/flakey/*","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","build-example":"cd examples/webpack && npm run build-with-parent","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --forceExit --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --forceExit --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{"test":"test","example":"examples"},"_nodeVersion":"14.15.4","dependencies":{"qs":"^6.9.6","ws":"^7.4.2","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^5.1.1","bufferutil":"^4.0.3","node-fetch":"^2.6.1","typescript":"^4.1.4","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.13","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/sha2":"^5.0.7","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.9","@ethersproject/wallet":"^5.0.10","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.13","@ethersproject/address":"^5.0.9","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.13","@ethersproject/contracts":"^5.0.9","@ethersproject/keccak256":"^5.0.7","@ethersproject/providers":"^5.0.19","@ethersproject/transactions":"^5.0.9"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.26","core-js":"^3.8.3","express":"^4.17.1","webpack":"^4.46.0","@types/qs":"^6.9.5","benchmark":"^2.1.4","@babel/cli":"^7.12.10","nightwatch":"^1.5.1","@babel/core":"^7.12.10","@types/jest":"^26.0.20","async-mutex":"^0.2.6","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.4.0","@types/debug":"^4.1.5","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@babel/preset-env":"^7.12.11","streamr-test-utils":"^1.3.0","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.2.1","terser-webpack-plugin":"^4.2.3","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.13","@typescript-eslint/parser":"^4.15.1","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.15","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.15.1","@babel/plugin-proposal-class-properties":"^7.12.1","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.1"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.7_1614114598071_0.27048253916917875","host":"s3://npm-registry-packages"}},"5.0.0-alpha.5":{"name":"streamr-client","version":"5.0.0-alpha.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.5","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3d29f91df7143f60d528b68b02b98340eb438d73","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.5.tgz","fileCount":238,"integrity":"sha512-ca/lo1VVvGbu+TL5ECiWA2GzIXn4el4sfEmooeLAckMwcU1BQuWApgwXgW5WfeEcpx6kggZt1hO0gtXT2qqV8A==","signatures":[{"sig":"MEQCIDVjOeHTh7P9LhC1WnNopI+VpmBk4SYr0uXXEmOXpf6MAiANgCSriUsECTP+KdBOtOwov7vsM0dqbwqNC7PT2AgTMw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29802771,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSdpyCRA9TVsSAnZWagAA2csP/AskFPvmICmr2LCEwbAx\nxNalQ1ONNGdw13ygf4d7pVhPonR3nak+sLY0sTEaoiZpHM2JXwKYuKxff7NS\nPIWY5vq2jzewTqeRXln685yTyeYlpaIoINsu+zMrWFsVeEQym3QyctPTA1mj\nIZx/jNLfTQRRyh48qd1QrhBFTZEPZUGl6FD/D8w38T+FOwVtabbibOywxwqt\nxJ8hX9j2SjNYOSWajB9sdRa6LeNt4U/B3IQkfDnylGytb2JkZeGccgFPaEI/\ns4hBEOkga+TWZ4Y8tTCkuLdGvQzfvb+D0kH2tDF5YX58fRAqjw2QnXh/N5ym\nNX2eXeaGCB16GTC4jSS1OjxuZN3APHUX/VassjYuB/n2FssO2uJIjCv5q3jp\nEJgOaWtmJKqGpO7jbybRIe/E3jMHyfbHKQdDyt8O2w6Eqf1Jb2iZsEMwH8Yl\nx7ZmmDfUKmwyUgbARRVwraAYHfpWea/3rm0jp0csTLu87PM+O+++QKpDGcb7\nSvUEsuy0CrbRdlqWI7qfF6Hycj+tsU+fhrVs05ZFqP5bV21z+/LKiS526cNY\nbqfKG7T1BaozfQS2YsDW2IQySN+IOWfMn28ehVNGNMuRyqciGBx4rV/2phKB\noYC70X8YS+tD3r9fFoW51AseQcKv0bBWgR2c94jNJMJEWUDhtAlGujZ/ew1N\nzX6T\r\n=zXqa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated.**\n\nNote: **Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. To get a DataUnion instance, call `client.getDataUnion(address)`. To deploy a new DataUnion, call `deployDataUnion(options)`\n\nTODO: All `options`-parameters should be documented (see TypeScript interfaces for the definitions)\n\nThese DataUnion-specific options are used from `StreamrClient` options:\n| Property                            | Default                                                | Description                                                                                                      |\n| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| tokenAddress                        | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU                                                                                             |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| dataUnion.freeWithdraw              | false                                                  | true = someone else pays for the gas when transporting the withdraw tx to mainnet; false = client does the transport as self-service and pays the mainnet gas costs |\n| dataUnion.factoryMainnetAddress     | TODO                                                   | Data Union factory that creates a new Data Union                                                                 |\n| dataUnion.factorySidechainAddress   | TODO                                                   |                                                                                                                  |\n| dataUnion.templateMainnetAddress    | TODO                                                   |                                                                                                                  |\n| dataUnion.templateSidechainAddress  | TODO                                                   |                                                                                                                  |\n\n\n### Admin Functions\n\n| Name                                                                        | Returns             | Description                                                    |\n| :-------------------------------------------------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])                                                       | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList, \\[options])                                   | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList, \\[options])                                | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress, \\[options])                              |                     |                                                                |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature, \\[options]) |                     |                                                                |\n| setAdminFee(newFeeFraction)                                                 | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n### Member functions\n\n| Name                                                            | Returns             | Description                                                                 |\n| :-------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                 | JoinRequest         | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                         | boolean             |                                                                             |\n| withdrawAll(\\[options])                                         | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress, \\[options])                     | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                             | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)          | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\n\nconst signature = await client.signWithdrawAllTo(recipientAddress)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nconst client = new StreamrClient({\n    dataUnion,\n})\n\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                                                                                                                                                                                                                       |\n| :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n| getTokenBalance(address)                | `BigNumber`                                     | Mainnet DATA token balance                       |\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"4c36d40589c05bd5997930f76223a3494e217939","scripts":{"test":"jest --detectOpenHandles","build":"rm -rf dist; rm -rf vendor; npm run bootstrap-dist && npm run build-browser && npm run build-node && npm run build:types","watch":"webpack --progress --watch --mode=development","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","vendor":"mkdir -p vendor/quick-lru; cp -n node_modules/quick-lru/index.d.ts vendor/quick-lru; cp -n node_modules/quick-lru/index.js vendor/quick-lru; true","fix-esm":"mkdir -p dist/src/; cp -Rf src/index-esm.mjs dist/src/index-esm.mjs","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","build-node":"npm run bootstrap-dist && tsc --incremental --project ./tsconfig.node.json","test-types":"(cd test/exports && npm run link) && tsc --noEmit --incremental --project ./tsconfig.test.json","watch-node":"npm run bootstrap-dist && tsc --incremental --watch --project ./tsconfig.node.json","build:types":"tsc --incremental --emitDeclarationOnly --stripInternal","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; rm -rf vendor; jest --clearCache;","postinstall":"npm run vendor","test-flakey":"jest --forceExit test/flakey/*","copy-package":"mkdir -p dist/; cp -Rf package.json package-lock.json dist","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","test-exports":"cd test/exports && npm run link && npm test","build-browser":"npm run bootstrap-dist && NODE_ENV=production webpack --mode=production --progress ","build-example":"cd examples/webpack && npm run build-with-parent","watch-browser":"npm run bootstrap-dist && webpack --progress --watch","bootstrap-dist":"npm run vendor && npm run copy-package && npm run fix-esm","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --forceExit --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --forceExit --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test","example":"examples"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.5_1615452786078_0.5295775162968577","host":"s3://npm-registry-packages"}},"5.0.0-alpha.6":{"name":"streamr-client","version":"5.0.0-alpha.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.6","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"f268f800f58c1b1a76aee8d91f64926ce697f9e3","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.6.tgz","fileCount":97,"integrity":"sha512-wcu1cBcA28kiLbiBQSc7c+FXwLcOlgUGK0M3nkxYfwwjyhYVFXhQqKATzF1FWhImMgW8IAo7ONxs1BpROMuRVw==","signatures":[{"sig":"MEUCIDao5F/lWs+lLC0aPXF6NQYZGam0APUSM78ScyVoB6cwAiEA3tdVfBaGr8aBZMh1lITwu8hI3uedz4ES+YVcKvP7WMI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21402130,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSe1lCRA9TVsSAnZWagAAiRkP/0mYDB/t4eXcZKLJMe15\niQPlqlzy4WqYyw4i2XygI6hfGscay+c7//tQ8QgX/btCcXabXTt3SZ4u/apu\n1FVoXrF0QiSAAdq27y8PxIZlNZlpsjO7jfb69t+twDwHAVCXdbEsfEAz+XW4\nQcEpruAd+IBSEjHFR+DGWh57MWBJNwcTibKnwc89UkdjkSqNT8EOn7KTI1HN\nRPNCtOSZLCZ0h9YHog5bgnudk+9J998w6hYCmZlJR2JnpM2J6uUEzuV8a5Wo\nxyKGqE8kjQMPry72Ya6HnBmqVjZkSl4G1uA+5KyFYiyvvff+UzyDXtqTjb8r\nJO59a0WnXeu8cLqZ4XF+5Fy/XrOuH0habeR2QX1xLJ4KSbMV1HlUTDtCcq8Y\nqHW9Sj0NlUOzFfSPQTE+bFvuTSPQhp4t4cd3HP6ronJ9iP4UUzkG3zVOxVNK\nKPR7frLeZlJoJolA05BSHFLp61dm0CDRn5LL12f8xsiVT+f+y3YTTjTztyRa\n/3LaFBIbr7A8ZU//fPhdshBnVpxzWLj2Aya6W793ZfUzzSkuuAZFcw8t3pSX\ncP+lB1XmM0R0lL6VessOxX3vp5ppNDNHn4qcBLQ/QJpnzSHpMQ50JN+N906T\nS7lLK4yZwd54yhrh9Y1Y2OJx8IvvjE6P0NpBipwXCMvuUNP37DIeSh/di0wl\nJkKW\r\n=mv/M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"ERROR: No README data found!","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"scripts":{"test":"jest --detectOpenHandles","build":"rm -rf dist; rm -rf vendor; npm run bootstrap-dist && npm run build-browser && npm run build-node && npm run build:types","watch":"webpack --progress --watch --mode=development","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","vendor":"mkdir -p vendor/quick-lru; cp -n node_modules/quick-lru/index.d.ts vendor/quick-lru; cp -n node_modules/quick-lru/index.js vendor/quick-lru; true","fix-esm":"mkdir -p dist/src/; cp -Rf src/index-esm.mjs dist/src/index-esm.mjs","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","build-node":"npm run bootstrap-dist && tsc --incremental --project ./tsconfig.node.json","test-types":"(cd test/exports && npm run link) && tsc --noEmit --incremental --project ./tsconfig.test.json","watch-node":"npm run bootstrap-dist && tsc --incremental --watch --project ./tsconfig.node.json","build:types":"tsc --incremental --emitDeclarationOnly --stripInternal","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; rm -rf vendor; jest --clearCache;","postinstall":"npm run vendor","test-flakey":"jest --forceExit test/flakey/*","copy-package":"mkdir -p dist/; cp -Rf package.json package-lock.json dist","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","test-exports":"cd test/exports && npm run link && npm test","build-browser":"npm run bootstrap-dist && NODE_ENV=production webpack --mode=production --progress ","build-example":"cd examples/webpack && npm run build-with-parent","watch-browser":"npm run bootstrap-dist && webpack --progress --watch","bootstrap-dist":"npm run vendor && npm run copy-package && npm run fix-esm","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --forceExit --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --forceExit --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test","example":"examples"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.6_1615457636016_0.7935576386516818","host":"s3://npm-registry-packages"}},"5.0.0-alpha.7":{"name":"streamr-client","version":"5.0.0-alpha.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-alpha.7","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9068a822a0bf4059c746a3c71251ac7b3ba6a431","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-alpha.7.tgz","fileCount":96,"integrity":"sha512-AuIJ4cVqMG1Tgxa7SqLDTlQu4USsMJdt1Ip1ZnwzqH5x1RdOoRjCNqPlG69R0GSmHBmH1i8eCCrs7o8MDfn6yQ==","signatures":[{"sig":"MEQCIAX5dVzxhvQQqG4qE9AD0pkOL/tHExDcpfFi6YZVCTMnAiAW7CQMcp2xpgplQ/+F8qgM7gVmuPbJTcDjjhGCPjGU+Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12705038,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSe2eCRA9TVsSAnZWagAA89QP/ijOVRwXyWg6ZbqSlMAS\n2MrvH+uOtofn7heb/25dUoLyQwECOV8bHPn5jcZjFCADd3EKzjbn3rjq5HIP\nH2/Pu1fXF5J7+aDxuX7kJo0eUWoQZBHKGYyT9tdSsoHN9PG5Sehuug0nhWMj\nE6MBz2wtQwiR/iep28gl+K+CYIs30GYZwc7IkV7IZoal20gQ6QfOnmUKIHpH\npnkoira3FtFtJTk8ferBxadoULaOFw+syxxKN8wJd+ZxVfntE4CYa1NlU3YG\n+sOorcx/pg0EzoxD4cYPNDj5UAsmWv3u+MZYhS9rvUeWKRdj4rOcc+IuvWs/\ncaLGtvFJi0pfvEc5bJz0+CCd7vWmwAMzOMGfiNQI16rU1+Q/Ag5eU0DSuIg7\nVGJkqXhtxtWMBtQlQdC84+hjbozdIk5DZidaTRRzDmPoatGhWzQ61onXd+8C\nvJxxvlMkdSk/D4vuOfQEieem4DoGy6eu4iH790288xQPVN0+lASh1V6TDE/n\njOUsHEstf9pFGIwLeyPwNwpamvuzJECRSA6oayfeLSHfWbbVHAhEA6eO/CAI\nC5roeEr0AOP6Mn8uVXkt9o0u0yuL/MDhBnz0j+tbjxfGzOsFRJlv1PaDvmBJ\nSLijwPlhkfNQwXT/VGmridxDWo3YDBxyP/u/aVJqEzfSLQ3cysFrEx3N0TGL\nT7Lk\r\n=gbPE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"scripts":{"test":"jest --detectOpenHandles","build":"rm -rf dist; rm -rf vendor; npm run bootstrap-dist && npm run build-browser && npm run build-node && npm run build:types","watch":"webpack --progress --watch --mode=development","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","vendor":"mkdir -p vendor/quick-lru; cp -n node_modules/quick-lru/index.d.ts vendor/quick-lru; cp -n node_modules/quick-lru/index.js vendor/quick-lru; true","fix-esm":"mkdir -p dist/src/; cp -Rf src/index-esm.mjs dist/src/index-esm.mjs","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","build-node":"npm run bootstrap-dist && tsc --incremental --project ./tsconfig.node.json","test-types":"(cd test/exports && npm run link) && tsc --noEmit --incremental --project ./tsconfig.test.json","watch-node":"npm run bootstrap-dist && tsc --incremental --watch --project ./tsconfig.node.json","build:types":"tsc --incremental --emitDeclarationOnly --stripInternal","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; rm -rf vendor; jest --clearCache;","postinstall":"npm run vendor","test-flakey":"jest --forceExit test/flakey/*","copy-package":"mkdir -p dist/; cp -Rf package.json package-lock.json dist","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","test-exports":"cd test/exports && npm run link && npm test","build-browser":"npm run bootstrap-dist && NODE_ENV=production webpack --mode=production --progress ","build-example":"cd examples/webpack && npm run build-with-parent","watch-browser":"npm run bootstrap-dist && webpack --progress --watch","bootstrap-dist":"npm run vendor && npm run copy-package && npm run fix-esm","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --forceExit --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --forceExit --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported alpha version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{"test":"test","example":"examples"},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-alpha.7_1615457693650_0.06395615691956436","host":"s3://npm-registry-packages"}},"5.0.0-beta.8":{"name":"streamr-client","version":"5.0.0-beta.8","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.8","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ac6a1adaa025601819b59801b4a9d264d1963f80","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.8.tgz","fileCount":242,"integrity":"sha512-C/x6lC5emv0pyFaKQpxSOgSKXpCFFMa5K8Fv6K0B5idWeG/UFJTZ9JgY4pf/wFLZ2YzFXWCgB46dparxKUSHAA==","signatures":[{"sig":"MEYCIQDw+dMfSrVLWoieU6DspNlR93HC6c8OiPOQjlo/0pqgZAIhAK/CtpqxvXzPQVz7T2jFDSzjlr0kbfF4s41Vq+K5UMME","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20646490,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSjVSCRA9TVsSAnZWagAA/c8P/RWKSr/q8ENPuPSqlTQI\nfHDmZMvwEL0fUvxzpYGoRRkYNvrfSPyYEbHquOqB+N5JyWWkQY3VyBfbKL8w\nL3Wkd/knlFo71VWbBWYvohWSUGf3aj+ZPo89fLmp8NmSUus3lYWExHd+httW\neDB1DUzckdovnNtgn94toAXy3NauadUHtMe0d47u0DYzR9RxHL6FjLnCVRwu\nkISkTQQYwi8uCpH93ioUHlBoNHAQzqxHZam5XfEyH2WYki2VIqOBWz6Zhxyz\nposIKQzQsPoeTHOywl5zczUiXClLn/eBlkHh91auaKoataqphc+MNTAGvxNP\nAEF/LxbM3B0aUNCzifgPsSdDRJfi3Kdg2udOpns4mdgfy+9p+mNHmXdzXhwx\nxUuxU/oChq2LCoUfUQPB7OLrgzNzm4vD25lRslvAiP5MBpoIWNSQf6aLeLz5\nvRQ+wIyfhMdwCe5nL70iBo7DgDDwGya+8O0peGeAYwTUUxax9qRevrjBVYVy\nXiiMp1P49/eW7P1gBJv/Ww6FUUG40LEdNj8klFCcxUfTgpvs71GHR9//aLEf\nTcBaEmAB3xyWV7ORcOeNlhO1vrjXlC4U91PCYpDPCEFNViFP+v0vqd76TeCP\ni3YOdjA/tYrRmn0z0fFc4+Jg5nBQn35UOXIk5vN4Tpq9/Osm9U+IKtAdeIuq\nK+11\r\n=f9Eh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams.\n\nThe client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n\n## Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n[Installation](#installation) · [Usage](#usage) · [Client options](#client-options) · [Authentication options](#authentication-options) · [Message handler callback](#message-handler-callback) · [StreamrClient object](#streamrclient-object) · [Stream object](#stream-object) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#binding-to-events) · [Partitioning](#partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n`npm install streamr-client`\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated.**\n\nNote: **Support for email/password authentication will be dropped in the future and cryptographic keys/wallets will be the only supported method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. To get a DataUnion instance, call `client.getDataUnion(address)`. To deploy a new DataUnion, call `deployDataUnion(options)`\n\nTODO: All `options`-parameters should be documented (see TypeScript interfaces for the definitions)\n\nThese DataUnion-specific options are used from `StreamrClient` options:\n| Property                            | Default                                                | Description                                                                                                      |\n| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| tokenAddress                        | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU                                                                                             |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| dataUnion.freeWithdraw              | false                                                  | true = someone else pays for the gas when transporting the withdraw tx to mainnet; false = client does the transport as self-service and pays the mainnet gas costs |\n| dataUnion.factoryMainnetAddress     | TODO                                                   | Data Union factory that creates a new Data Union                                                                 |\n| dataUnion.factorySidechainAddress   | TODO                                                   |                                                                                                                  |\n| dataUnion.templateMainnetAddress    | TODO                                                   |                                                                                                                  |\n| dataUnion.templateSidechainAddress  | TODO                                                   |                                                                                                                  |\n\n\n### Admin Functions\n\n| Name                                                                        | Returns             | Description                                                    |\n| :-------------------------------------------------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])                                                       | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList, \\[options])                                   | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList, \\[options])                                | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress, \\[options])                              |                     |                                                                |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature, \\[options]) |                     |                                                                |\n| setAdminFee(newFeeFraction)                                                 | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n\nHere's an example how to deploy a data union contract and set the admin fee:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion()\nawait client.setAdminFee(0.3, { dataUnion })\n```\n\n### Member functions\n\n| Name                                                            | Returns             | Description                                                                 |\n| :-------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                 | JoinRequest         | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                         | boolean             |                                                                             |\n| withdrawAll(\\[options])                                         | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress, \\[options])                     | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                             | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)          | Signature (string)  | Signature that can be used to withdraw tokens to given recipientAddress     |\n\nHere's an example how to sign off on a withdraw to (any) recipientAddress:\n\n```js\nconst client = new StreamrClient({\n    auth: { privateKey },\n    dataUnion,\n})\n\nconst signature = await client.signWithdrawAllTo(recipientAddress)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nconst client = new StreamrClient({\n    dataUnion,\n})\n\nconst withdrawableWei = await client.getMemberBalance(memberAddress)\n```\n\n## Utility functions\n\n| Name                                    | Description                                                                                                                                                                                                                                                       |\n| :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| StreamrClient.generateEthereumAccount() | Generates a random Ethereum private key and returns an object with fields `address` and privateKey. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document. |\n| getTokenBalance(address)                | `BigNumber`                                     | Mainnet DATA token balance                       |\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"ed6375a697d8a70b9b2d07a0bb5ebf8c6770e964","scripts":{"test":"jest --detectOpenHandles","build":"rm -rf dist; rm -rf vendor; npm run bootstrap-dist && npm run build-browser && npm run build-node && npm run build:types","watch":"webpack --progress --watch --mode=development","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","vendor":"mkdir -p vendor/quick-lru; cp -n node_modules/quick-lru/index.d.ts vendor/quick-lru; cp -n node_modules/quick-lru/index.js vendor/quick-lru; true","fix-esm":"mkdir -p dist/src/; cp -Rf src/index-esm.mjs dist/src/index-esm.mjs","prepack":"npm run build","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","build-node":"npm run bootstrap-dist && tsc --incremental --project ./tsconfig.node.json","test-types":"(cd test/exports && npm run link) && tsc --noEmit --incremental --project ./tsconfig.test.json","watch-node":"npm run bootstrap-dist && tsc --incremental --watch --project ./tsconfig.node.json","build:types":"tsc --incremental --emitDeclarationOnly --stripInternal","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; rm -rf vendor; jest --clearCache;","postinstall":"npm run vendor","test-flakey":"jest --forceExit test/flakey/*","copy-package":"mkdir -p dist/; node copy-package.js; cp -f package-lock.json dist; true","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","test-exports":"cd test/exports && npm run link && npm test","build-browser":"npm run bootstrap-dist && NODE_ENV=production webpack --mode=production --progress ","build-example":"cd examples/webpack && npm run build-with-parent","watch-browser":"npm run bootstrap-dist && webpack --progress --watch","bootstrap-dist":"npm run vendor && npm run copy-package && npm run fix-esm","postbuild-node":"npm run copy-package","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --forceExit --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.js","test-integration-no-resend":"jest --forceExit --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.js","test-integration-dataunions":"jest --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.8_1615476049641_0.5526095091698937","host":"s3://npm-registry-packages"}},"5.0.0-beta.9":{"name":"streamr-client","version":"5.0.0-beta.9","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.9","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ee313e15234d57f0eee451bf475c76cf64f6a840","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.9.tgz","fileCount":95,"integrity":"sha512-C8iw3zRCXuaWFejPRSKyWwKFGWnSY9z8EH3X5Mm/syHp+RZKbZPVUk/Y3ByVL7mhctE44thaKCxdCyAL0qXovg==","signatures":[{"sig":"MEYCIQDlbLyyuey41flaS3O7LnQfg4Z9k+8W1O9m60c9Ryr60gIhAOE4lv+ahA/59XWrP7BcseJZcQFfz4PF+7bZdVi6fzwx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12698578,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSjaBCRA9TVsSAnZWagAAsk8QAIav3pq4y2Me9DrU9MQq\nGFcul9s8laLny7D/73wYmqbAdTDZenhCcdPsbW+5evWPWe9SvH5eh2ts7iQF\nr8b+iC25IPfQde3gCnuHdGpSRwsxW9gediNKBtIt1rEqQv4WDJGJjpep7h1M\nAaa/HPeCGF1hOj0Bp3ruq7U/8cq5DksWAEa+R9J8rEd24XNjN0kRl0cBF+iQ\nYIk3v5+Kmkv4T4RfNDwFR1TVRlvpB2wmsNj2NDkYxuwfFxu6CFiL8U9ixtPs\nHlWiOK/R/dxcakXMG1fsVv1aOBFrYGnQJzNAgGoff9Pc4DwNlikT4t1VbN5i\ncP9BPcbvRc83SFNSmzD0VxhNuBRJtGJY5wsU4ttbq84eQx3F/i0wja6QwONf\nyih3MuX5YlGPzPlCuUgnj17Y9WEaLFwVZNjfQ0RV4F1mJb1YwXqvQkg9frZR\nGk7Dnsqs328pnmNmIp5U/ItJB3oebLfLCzMiw7FEtJS1KVhGe+IEVPUJENlX\ns11EWjWafcds3FuXRIe/YfK4PWeYHB6VwHior6LUopxvjf5nEIUkwOKxS23O\nsnzrCW33Xr8FoiTc3FnSklRsSXMIHcuXeFy7X4WW2MX8rPeU5nvucYeGvXNA\n2SAzJdXF6aV4Qcz3drJh6xUMTcEDZy9xsrdfW3AWg8uT31oGgFT4XGEY2iPx\n5N4A\r\n=Bnk7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"ERROR: No README data found!","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.9_1615476352744_0.32828620899359007","host":"s3://npm-registry-packages"}},"5.0.0-beta.10":{"name":"streamr-client","version":"5.0.0-beta.10","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0-beta.10","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"4bd5686c27934e1af62e788524a6b7acb3b9a3c7","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0-beta.10.tgz","fileCount":95,"integrity":"sha512-60vZbiLcIwDKU2ZcehuHcpae+xYe0BHyP4Yha6y5i1YJSDCKoh+6mHzTb0sYCZQ1y7BquqWvOdiwF332qRfYRA==","signatures":[{"sig":"MEUCIDMNccChD7rWDmR6OLrZN/zJRvW5706fmkvqkjvFngbzAiEA+ynMTc9WHAbla8fhXwj+H7MqF18adR0fCoTjRyix5LM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12707814,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSz22CRA9TVsSAnZWagAAQycP/RXPjkSLXskUelCG9Y/Z\nKp8JzSyZhJzyHWhaZowMmBgdYZBOyiiSGBtiWWdpVQ9IQOuTK2nj3ObcciGq\nb+rLMzgRfdeaaSi59Kmrdq8Eea1L87pruOE6GoiECZvJUhULogzydnbVg+2U\nvWMmyPPlP0eNyGMMsS9v9feayhEoXDXThbSReDxUhj5Aojvgu9NFZepbQ6OB\nsxGGZl4J79fLhWbFsQoNK3oqgrggKPohy96sZ4pM/nBitjyT9bZ94jA4Lx+k\n0G3zw3OHkzhGcDWDy7+KGlCLZRmK0khTnDmXmRd/r7GwbNvB86KEAafFTUv4\nFWpKi47OAlEZDv/aiBBhrAv2JtAkNj11hoRHpT7J4VZps8ajY43YRI/OQ/JF\nu4UgjyuSVGB4G4GnijZaSO6Wad+ORDjs8zR2mxLtj4G/EI3iRafXxqT/kFp1\nzWWePx2EDPFhxyye7IAhhw+i364MraM/wqqkQoKRu0vfI87X7d7j1yKyWz11\n6Xn4BavsI6AdTS0S/H2lBQsTg1I+RLio+3YIXTfXQkPk/WwNThaMH7/1yJV9\nOdgeVoRU+vrYgso33TTJxWaPYoWj3ba84CGv85P9xpHycRtWBgMqjWm6yYQ5\nuuvNYbvP0kdFF82JWpk+ZHI0E5Ji+DnRYHmyyVdlbGe5WU7nXW2shU0oE/X3\nI0Ll\r\n=G57K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"ERROR: No README data found!","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.9","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.15.2","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0-beta.10_1615543733836_0.529740274916296","host":"s3://npm-registry-packages"}},"5.0.0":{"name":"streamr-client","version":"5.0.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.0","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0918737ed5a58815f4868a0320d1e0f10edf078c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.0.tgz","fileCount":95,"integrity":"sha512-7YXYen1AtjDL9AF1lyyfqVAblzMDXnlxFQ+2T8vTZpbJqn41HQ6olcSQnJjCactK7ULrf/2sPtWC/9YKXdTbtg==","signatures":[{"sig":"MEUCIGxylra2yOYcAQt7UJXQQCyM09UjIDDndv/Nz0WsXHkKAiEA/X9OD60iHxIu/Q1WrtkBs2tyrekYVbXCQ9UPDWPMWm4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12714319,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS6wfCRA9TVsSAnZWagAANcMQAIfDl9w6rVKexTcY5SA3\na65bZCmmS/jaJ3WaaAblvahMRld4XKvLiu8eLwYvEohO4Xc5RAVibQRsLLiZ\naua1mgzzDsJaVIOgwBHnSRGdmWYXlzvYkmFQj/0+r3kh5DxtD32TOvWZB8mE\n+9OtsOQ6etwAxoL5+1EIj4voSiyL5osMGOX7JGMvccCu2v26wrHULBiCoHLU\noFNHC8FEM2B9mZtW2THGebxj4zceM2Dqhvm3PfLs2sN0Cp/slDX5MSRjq+LE\nC97cohThPDJ5PU6LOxRRkyFchjAjGKZWlU0cXTpBkJUpTfxCL6mSmq8g5SJZ\nRMavLbOuyWX4iOw9ZaVav/p5jA8a+5uRSv7gJrHWy83xoBOIz55EC/0yVGnv\nAGcuCozgNMMyaErH7jq+mwG6gvam5nPKyDgmNDhR6ZB7q1z4t77Ofecf/8QZ\nECW0dnpVIuQVm7VPhz7R/3qgdvXQe2Njb5VuwU263oppaRvuMp4MgRR1fYKm\nUhmEMPdfQtycVTdKzqMJ3l0pHVSUng0qWFONIzVmGLS/ADxKdS0l9W7mUWoZ\n/LW67/QcFKbUFGcdALxGhcLH6uiTP7aLBDwsa4WHXF7aVVDiJNBUsU/lZpU6\nQE4MfHB15rpZ5A8zqtTJFHvfYs7JAPkjA/3KKhDtNh7yD9CKZgm7LuZ/w4a9\nGOhA\r\n=nqxS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This version has a memory leak. Fixed in streamr-client@5.2.1.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.0_1615571999073_0.376718922798877","host":"s3://npm-registry-packages"}},"5.0.1":{"name":"streamr-client","version":"5.0.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.0.1","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"96fe898026c5f5d07b14e422c52f4e4e10771009","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.0.1.tgz","fileCount":98,"integrity":"sha512-D0Y1Ss/sHq7gVHdWx6zFd6XGny/FLsRQGjonTJy8pfZZ+NAWmDE4WtHKI6dTy/5Z+Cio7SBeKYxsAQBx+DpKhQ==","signatures":[{"sig":"MEQCIAPbcB7Q87LSwZcKZa9E3AVRR5FivMnS/XpJUdoZ8RObAiAmi+Hj0UTLZpIjzZFYe+QfvfDHXDPJwgbmFFX7sRkfDw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13196996,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS77hCRA9TVsSAnZWagAAq9gP/0ynB2zA1J2wyGstLuZ1\nqb3KnVH1SRaeZKcSuI1EBQnl9eux9VIGuWanqftotrtR15Na/iX4VByE6VSU\n3C8yUkrjtfXc1C9PBoBRXBUmEmlTNFHulm7DWNsgnBWuHcd18DawXCxbDhad\nO+qsl3aGqIsGEqOXaeQHulM5aer8wNpWZ+qYo5mZMTeHJuN3u0sA72NxLKsJ\na3N9B8NjdEQgLSyV3OC+RBxzMva4DSAgMMe++S1RIOL99Gn79Zi8QxGrt3tL\nxY6j3IbiiPqiFWyYMKF9DhYHfyQWuHJamynULAaOCOL/++lIhCGaNW8Q6kIu\nhQRxm0KemGzR1tdnpbCxKVw5Cl18AaSevAC5Hrw3r4PVPEM5vBU5yfekg0po\nPrcwT35JQB3iatlIdLafqqUWb4X+dojr4coBQuNBFrEwe2M0w2aBUONNjKSy\nadSaC6s8SyssSBL58Q7gPaGHFnDhmEjQlWCz7RC/XU0Soy3vLVTT5jO7xTlw\nNmzud8Sd6wlb5jG1UX6DQ5/vurMXJCtyjn2KPIydxZ+hnaYGYDetCb9IyFRh\nqwncYSMfwqqMZIpgGzcd4mawdAWlfSiXo8VxIYn7Bzc49jFnUvm9pzy68MMh\nYrMLB6NSVfhu5hkH5hdwxE5bUul96weXtTJUezqclfHygDYWrThvbXHc2F8U\nnDmn\r\n=YxlE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This version has a memory leak. Fixed in streamr-client@5.2.1.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","lodash.uniqueid":"^4.0.1","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node14":"^1.0.0","@babel/preset-env":"^7.12.17","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.0.1_1615576800778_0.5196851313557791","host":"s3://npm-registry-packages"}},"5.1.0":{"name":"streamr-client","version":"5.1.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.1.0","maintainers":[{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"d60df7d1791ce0e92d68872200e058c1371b8f68","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.1.0.tgz","fileCount":98,"integrity":"sha512-+RltKvWFF702V+gxzoS+MklAANBcGcURiR9DzHefBBy6H6++EBD8tSAML2qrGr2vBiLYIsYGRSQrlaNefNL33g==","signatures":[{"sig":"MEYCIQDzLzlV+NxmLJ3q9qynDuocqojxDRFrsM8EECicTzTzJwIhAN68ynXiuVYxS6kWbk+5nimQXHYCAQEoGqYHD21Ga6az","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13266156,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgT7+1CRA9TVsSAnZWagAAHPUP+wTZXSsZjEcnJg8edAun\nsWtANFQIwJbZjmtbxMYeFJtVOFQzdrP3KVvjVXhq8AY0y4eLeK0miuFz42z/\nHMPOXXbeYl1lWnD1hYqG2yFFWlfu4IBOiaOmC8fNjj9fUs6hNYA/uA1FE4xy\nyiRHBSACr+PPY+RP9siAu6B+J7j7Xxk/1/E/688FRyc4fUAtOOnVfTXAwfIW\nCw7/XboWpUkXZkeSsPkwTpgGiHVe80dgiHTAZ8tqCE/R1S+JIEZ6P8TkJDKu\niDO4AwgmhH3fhui0a5TGj4Jo6dkTVqyUKhTsPAPSs6Kiz6VwH31xazS3XR9K\nXP3UtZ4JmNIr/IdzEfJ5Md/bzDY7lRKzNsvjwqx08A+KH2SoqdUDmv2RpUwO\n7kbhJiYnIQsJzevMaeUaGeAaqLrQ6nXiRG0HOcvumII+frkmfDRm4639/Nmw\n7d6RRpQWzt0eunXpMBErfx1WMZfG6/TMakSH3aaAu4m26afbbsSukcBQMNyY\n+BoLWipqzsSGv26xbJ8p1fPdoQREneQ0X19U+J4fjXGsqtux7FXWsdAteCeu\ntIYzDTBYI2fYG3lpLlnpdNG3wNgbQnHV748RTaxJVoy6a16Zi5rLrr8bUiws\nX1vmBck9bCIlzo+C9FXMrXSVs9wjPVrtsXvbxTmf57xkmYHw52nTMHoSJzxY\n0nBG\r\n=Yz0E\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This version has a memory leak. Fixed in streamr-client@5.2.1.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","typedoc":"^0.20.30","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@tsconfig/node12":"^1.0.0","@babel/preset-env":"^7.12.17","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.1.0_1615839156516_0.6989465026777906","host":"s3://npm-registry-packages"}},"5.2.0-beta":{"name":"streamr-client","version":"5.2.0-beta","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.2.0-beta","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"f2e6edb6ef41b5655c49c326d92e3e3ee18318ea","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.2.0-beta.tgz","fileCount":98,"integrity":"sha512-ca0qNNWECvWjNezmH4iSmO2+R05+BY94fJzFPoSWlwMClLxJM+lO8Yt1KssduAeT086IDMBoVhj7n+m2A4VgjQ==","signatures":[{"sig":"MEQCIAh4PSAeVQ62S4jN1MYQTuUtSk30p/CAkgM7jqQ+V/YxAiAm1eY7z84vidakg746wvGfXqZN1nzhP0kcl7acUD+zrA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13263971,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXRVqCRA9TVsSAnZWagAA0MoQAIP0ORZmci7QmkWTf6oW\n8b+7Sy7BrXhvRRbQAzwKlnH5qKIxyiKP45tsZTmqqdDWpyr4gEXJ2+9OpzCV\nt0WsjLvXwbT7WSwcb8pnunEyooNDtq2Fa5P8sDWl/gZOUN4y2eKT4MQnoRFH\nkCnBbBqtes6n6aDvXnY1FPejDuF9HpgoQBozVDik71SzxFDdWa6vAlH/I6pa\nI0EQB4hgnFFBWZSQW9nrj7GDmJz3D2D22bB7z/lDUS+OLjV/saYtUiD2NIQD\nbEfMVbmLKhCZOtdhiH/9cY3C6euPdhLz20UplpbZv0a43QX7SMWEz1lITQZQ\nLFmOMFeJlovEPKMqoI9EMKN3lWkMLvMBvL4jizfjYENxwbpYQfIIqDxloFT0\ndHIzesoc+cyYMwJRScI+YnkoM89r4LOBJJcIRyVTXMDmuR6hGgG6iA+iEBcj\nxfmZjtRDEEFSUw9ALtlo/+6g92ChuYJxjVeWqEW9gDRFb/5l9ZDnQZXyi6rj\n6Qcm+y6iHlA4LYApnxMmv7Ay+SVxwawtUl+UR0VWYp4C7Vs11oacIvRCfVN1\nlZ6xrq5vRltOPQZ6Pp5lj7KZEnPGfw3CenXT6vZMHEUAF1S5MdfLdYD2c+Tz\nG2GEIYwJm+FHLJBnyrr+/+3Tq7hwqS2p+nNuj+uWQTMSGYh2hUxTPzm202As\nzWfV\r\n=dd3c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build Status](https://travis-ci.com/streamr-dev/streamr-client-javascript.svg?branch=master&style=flat)](https://travis-ci.com/streamr-dev/streamr-client-javascript)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                                      |\n| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| dataUnion.freeWithdraw              | false                                                  | true = someone else pays for the gas when transporting the withdraw tx to mainnet |\n|                                     |                                                        | false = client does the transport as self-service and pays the mainnet gas costs |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                              | Returns             | Description                                                                 |\n| :---------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                   | JoinRequest         | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                           | boolean             |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                     | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\]) | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                               | Signature (string)  | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)            | Signature (string)  | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                         |\n| :---------------- | :-------------------- | :---------------------------------------------------------------------------------- |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address) |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed               |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                           |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low), but a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This is an unsupported beta version. Please use streamr-client@5.2.1 and above.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^5.1.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","typedoc":"^0.20.30","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.0.1","@tsconfig/node12":"^1.0.0","@babel/preset-env":"^7.12.17","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","@commitlint/config-conventional":"^12.0.1","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.2.0-beta_1616713065379_0.16001247089342718","host":"s3://npm-registry-packages"}},"5.2.1":{"name":"streamr-client","version":"5.2.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.2.1","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a9e81f0b12cd1cb92ffa4967bc788c76577351ce","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.2.1.tgz","fileCount":98,"integrity":"sha512-C1yMzvuskjtRHHtftgEpSsGI74D+ZbJltZsZAjb3Vwt75h0R/zcTzacipNvJa4IbIRDMTIWhqvVJd185PSv3zQ==","signatures":[{"sig":"MEYCIQDUefeCLNrVxi0VrtUtXS3/U6nliSQP4At+xPYsKDSZwAIhAKdOqiX5My2qoXYPyG+bbho0yo9Z26bzbCYj+38oUlQG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13270387,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYidYCRA9TVsSAnZWagAAoRwQAKIzYeOH8FTqPpnUPCEn\nL0vHhBb77+j35geKiMrGki2LZL7DAAaOdQV3mJamQWsDemSSbRWEofSAcUht\nA2z5lOxTU9iZ89WkRQfVpb3RbO+PM1Sb8xmMqT0InRvVppi/RSOgq2lrEXJg\nDtvKiNA2lCV2seCjN9Lsp255XGuhDDFO85NcRoqGQz4ss4Q7Yr5HIf16tGuc\ni3WPFbRiOaZBljKiBl9edxwlI1m5KP2jRB+peHpAcLIEVxxx8XBa7IN4GGHG\n3rIo4rrqYD1QmsoUAiCgWmAhaXaxUaPGEC7C1q/5Xgil0UsWZP7il+OcS0ss\nEorHxOgryZ6Fr/jWzW+fSPLxffBZJ35jH37G9vlt9OUVfd7m5WQkPhclqA+x\nLua1YBkivPDA4jEcaJtactbduShyZhCogobJn8B9FaXtN8QiUbgQaerdCTX4\nLdI24xc92+58yCYPEkAa+OhvdDLQGCUjf0/IPcII6wP95VIgL4zgMdcfDF52\nFrvSau6KVHbTUzQaXqvElkDaKJlvQcfwwyhzHgXSoVXPYpnBovrqxok0Z0Es\nSUKSZ6HsiLlLksE43pnYcrUu7mXEOMmH4P9fIjAQTQ6Cmury3IokYzjn1GIs\njfyrpBTtOJj+IU0PBQEn8NMmPCjwZfEFljaxZ/xGz8zHNvniXPPci9MxO+uj\nchB6\r\n=IbrK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^5.1.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","typedoc":"^0.20.30","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.0.1","@tsconfig/node12":"^1.0.0","@babel/preset-env":"^7.12.17","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","@commitlint/config-conventional":"^12.0.1","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.2.1_1617045335534_0.8062600058531466","host":"s3://npm-registry-packages"}},"5.3.0-alpha.1":{"name":"streamr-client","version":"5.3.0-alpha.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.3.0-alpha.1","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"fe880c10897192635bfc293d9271cae83d82e638","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.3.0-alpha.1.tgz","fileCount":254,"integrity":"sha512-lv1UU3C31ESMKq6YdHHfQX+HFLxptNuFf3+QI+eHDlKFvXXTmLrxgwLyJpgy8yXOMR+EWAHaTVoLeuAVOfVQHg==","signatures":[{"sig":"MEUCIQDC91a34N0ocpuTWuknZ4JrmqawDvULau9nImJTsIg58wIgUw3DvLuZVCLX4ZEdLQg93+BwRVdn9DdI38KeWNsedio=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31017136,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYwDHCRA9TVsSAnZWagAAEpcP/iLqKOQyTzDYQByc7vv+\nRym28ug5IIi2KoISrehRkUATIuyUsCZlCNfAPNMeq7yWxM3Jyrndj+1ikZt3\nQWTMfliV9pqvL3QJlsqqk9f2mHe6tNFox0VKA9ne7X3b3T4X11YVboKqeMDs\ncZeznZtywBag6tsr9i+B1cfOJ37B0Aq2w9WyQ2AYjF9AEB8nTODzKv609Kc6\nC88EZAN9P9BFRO0SrCUNLbhLsb4eLqMt+uKsSsYZEhsDxcJGaSGPFCrtrR4f\nCCB990cUFevX6QW26/fZ+qElz/PVQStzdZa4G9p0mUWBxPwpvc8Iga1mJk7J\npvl13OvEZoHaeFLDerNg8iAho3qAyRhU6XWicfr1T2NE8PYVSmWr6YP5rMM2\nsHfcPcCxd6FP1phKJHEKQIcJNH7fqU8nyY4hz04kL720E03Fnhna6QQdGrJk\nMmaqKS3T70qlzYLIZBI0Aq9V08p44zs9p9I0+F5v32vUEMikE4Ft4zDzfqww\nOT4b5sjv84v83wv3H0ULaBUmfeIi/xDI9OEX1vyLes0MFKjcBxiIuFpWcWeH\ntIeIvbgtKM8F4NkbeZikDXeFBPNEadvlZMwo7lwKM63DRIbHb5ojH1q1Rf50\nJ/jboNJfkh4GcD0IrN/H7n481V12KTx+XvRwsaDgGr4smwuaPy4K0BJ1qIgN\n6FcF\r\n=djMV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                                      |\n| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| dataUnion.freeWithdraw              | false                                                  | true = someone else pays for the gas when transporting the withdraw tx to mainnet |\n|                                     |                                                        | false = client does the transport as self-service and pays the mainnet gas costs |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns             | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest         | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                               | boolean             |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)  | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)  | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt | Send the mainnet transaction to withdraw tokens from the sidechain | \n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the following options, e.g.:\n```js\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    sendToMainnet: true,\n    transportSignatures: false,\n    waitUntilTransportIsComplete: false,\n})\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                           |\n| :---------------- | :-------------------- | :----------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)   |\n| transportSignatures | true                | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge |\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                 |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                             |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n| | | | |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"99f2abf4e2126e46a5bb0da1c28abc6c337e20bc","scripts":{"docs":"typedoc --options typedoc.js","test":"jest --detectOpenHandles","build":"rm -rf dist; rm -rf vendor; npm run bootstrap-dist && npm run build-browser && npm run build-node && npm run build:types","watch":"webpack --progress --watch --mode=development","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","vendor":"mkdir -p vendor/quick-lru; cp -n node_modules/quick-lru/index.d.ts vendor/quick-lru; cp -n node_modules/quick-lru/index.js vendor/quick-lru; true","fix-esm":"mkdir -p dist/src/; cp -Rf src/index-esm.mjs dist/src/index-esm.mjs","prepack":"npm run build","prepare":"husky install","coverage":"jest --coverage","prebuild":"npm run eslint -- --cache","benchmark":"npm run benchmarks","test-unit":"jest test/unit --detectOpenHandles","benchmarks":"node test/benchmarks/publish.js && node test/benchmarks/subscribe.js","build-node":"npm run bootstrap-dist && tsc --incremental --project ./tsconfig.node.json","test-types":"(cd test/exports && npm run link) && tsc --noEmit --incremental --project ./tsconfig.test.json","watch-node":"npm run bootstrap-dist && tsc --incremental --watch --project ./tsconfig.node.json","build:types":"tsc --incremental --emitDeclarationOnly --stripInternal","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; rm -rf vendor; jest --clearCache;","postinstall":"npm run vendor","test-flakey":"jest --forceExit test/flakey/*","test-memory":"node --gc-global --predictable-gc-schedule node_modules/.bin/jest test/memory","copy-package":"mkdir -p dist/; node copy-package.js; cp -f package-lock.json dist; cp -f README.md dist; cp -f LICENSE dist; cp -f readme-header-img.png dist; true","test-browser":"node ./test/browser/server.js & node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","test-exports":"cd test/exports && npm run link && npm test","build-browser":"npm run bootstrap-dist && NODE_ENV=production webpack --mode=production --progress ","build-example":"cd examples/webpack && npm run build-with-parent","watch-browser":"npm run bootstrap-dist && webpack --progress --watch","bootstrap-dist":"npm run vendor && npm run copy-package && npm run fix-esm","postbuild-node":"npm run copy-package","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","test-integration":"jest --forceExit test/integration","prebuild-benchmark":"npm run build -- --config-name=node-lib","test-integration-resend":"jest --forceExit --testTimeout=15000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.*","test-integration-no-resend":"jest --forceExit --testTimeout=10000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.*","test-integration-dataunions":"jest --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^5.2.0","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","typedoc":"^0.20.30","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.0.1","@tsconfig/node12":"^1.0.0","@babel/preset-env":"^7.12.17","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","@commitlint/config-conventional":"^12.0.1","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.3.0-alpha.1_1617100999026_0.07078433769800907","host":"s3://npm-registry-packages"}},"5.3.0-alpha.2":{"name":"streamr-client","version":"5.3.0-alpha.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.3.0-alpha.2","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"569962b00bb07d61b6526d4e5e84c798dc3bee50","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.3.0-alpha.2.tgz","fileCount":98,"integrity":"sha512-RqbXZV2IdUEcdtEuE1EXFsdmF7sNrRoGpWodxHAi6jXu1PRh5o824R5ZmjG+x/6IPb7Pf7TtxGllfv0CcFuuVA==","signatures":[{"sig":"MEQCICDcrDKgz2pUO9RUIG+0mqWIXBqiaUlWFVSuCufHA1beAiAa1lckMeHpGRbQBZVoUGZwMa/MZSCg4ku5aMAUdkSbww==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13286018,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgZG7ECRA9TVsSAnZWagAAExQP/jNtzBHnMN7RhArQQBLm\nFEv+T9+L+39x2+oOGktf3FuELQssw83r0+O/CFoPUeoebqta26mTx6w5SAPR\nvk3jVNkdyD4uJHxU3pOkAHvfkLB/3OFgnpqZ9cLlesvI1TtOEPJK68/bYnvc\nDd7gqhJgizmJDRF30SQtqDcmp0x//hri49Vy1boRznJ04XWGB++GV1hidyxI\nI5xw6r+dU6K8ivhq5ETb2lkEdY+GCE/+fZN3ZYmIPaWE86M1b7SUAXmM76dz\nWX8wiU+FiOeLWdQA+7lKxQcJblFITDsLz/1ZDYBaYCwFgRVzxummDR+pXezT\nbJsW114wlghyhLc7kyqAh7dt/krQadE0gcaDU+Scfd4OoNPVpbsL00V2C11j\nH3UDEvvOc0Z7kutlwmkrCgVqdWOscgV6lQMSZlCDu9I/oMd9MJJTU67XIBqW\ncfVk6CRxRHhe9ec6uoD+IYsZEmlitPDCnUGNUPgeEoMmYA4+YR/gGKsBRH6P\nhwJG8P/HkVkvwjDMDtcmnMX5Kcp0xum6rP9bZqF/7hmpMqobQLVcdOa4ZWNh\neFoleN7hfdJiRBOmgj7suxgJmJDrkRRqJXHw/Ywf3rEBQ9SyIWnt4Bms2zol\nbnZv+AK27WqWdnA1Sro97Uf9eHXPtIm99+dDY6xN7++80tybvukxKrheZSoQ\nzAme\r\n=VPDh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                                      |\n| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| dataUnion.freeWithdraw              | false                                                  | true = someone else pays for the gas when transporting the withdraw tx to mainnet |\n|                                     |                                                        | false = client does the transport as self-service and pays the mainnet gas costs |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case. \n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    transportSignatures: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                           |\n| :---------------- | :-------------------- | :----------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)   |\n| transportSignatures | true                | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge |\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                 |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                             |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^5.2.0","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","typedoc":"^0.20.30","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.0.1","@tsconfig/node12":"^1.0.0","@babel/preset-env":"^7.12.17","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.1","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","@commitlint/config-conventional":"^12.0.1","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.3.0-alpha.2_1617194692005_0.7731290388005949","host":"s3://npm-registry-packages"}},"5.3.0-beta.0":{"name":"streamr-client","version":"5.3.0-beta.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.3.0-beta.0","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c65b02c7ac8d24cb30ab100974b2b6a5a272b0e2","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.3.0-beta.0.tgz","fileCount":98,"integrity":"sha512-KGz9KpgDMIeGr3MIf++3Gu+3M8Jg28mABsMWaW7Ssl5Ak6i1CR8Tov1tzIXwr+2tD9TxzqmSigcswc5hC7ijgQ==","signatures":[{"sig":"MEYCIQC47+PPVK8amVMixZ9Pz83OTuweaG2JPaLKrSKlnQkN3QIhAIrcqltO8CmjVu7kOXQTeKItNA6Zae4/MX83ZzAfIyzk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13310468,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdwXPCRA9TVsSAnZWagAAKVoP/2SR90p3tMj5626PQkIo\nJXjGDn6ZQhzkv6VJ+4g8+ZIWMqWtN9dMdc+bmGxlC2pjeRT7LUDxguXYgBO6\nZkVA1TjcWZFAVK79yHbDzNzlHHxSCSeLQzFw+x1qKC7lO69VDUrNKibnsYj3\nSOch+r5BRgtoXm5YcqWqzm/MzCRYvZhKK8f+k45F+SmNfDZfg/Cfqf213uL/\nYpZsDzIZVpoFZOY2CLcf30SaaHw7FctYGJhy+PQR1EXN/bhQAjqhzcwcMEIW\nT/Cn/QyF+USutbN05TTrqYEH7JZgDjLS0PuYZCnHBCPFBpehrbWh+mvlJobd\ndGWrbBu3HEjNwOXH4Qo5FtaNmaknOc1H6IjTIkC9pBjKiUwrP6EmyQoFA3T6\nuJYn/xViVCw+umAM6Sn+dwdYj8tYA0S/KIXhXGch3QJSjPNpLvi29/IAqDMZ\nL/avvLWgy7BIcU1YULzFURSaWMgYT561gibTCcgHBSoEGmk2jr6/meAK+jWI\njNjJ/cYfPHavaK+yGGJUs5dUw8xWbwgf+rRJ4Dr6JzbNpXxlarwanglqMpdU\nnuMIiZ2gLxsoyPgEphVk9RifQ/E4cB8HeUl12myyPm5kfD9t9sVBAjunr4lZ\nYflZc4cSOfow3dwJhlZUl806pPmmc3pmfU/0B6HJB8e8Nx+XUr4ewFte3LRF\n2vXt\r\n=YlRm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                                      |\n| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge                          |\n| dataUnion.freeWithdraw              | false                                                  | true = someone else pays for the gas when transporting the withdraw tx to mainnet |\n|                                     |                                                        | false = client does the transport as self-service and pays the mainnet gas costs |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                              | Returns             | Description                                                                 |\n| :---------------------------------------------------------------- | :------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                   | JoinRequest         | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                           | boolean             |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                     | Transaction receipt | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\]) | Transaction receipt | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                               | Signature (string)  | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)            | Signature (string)  | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                         |\n| :---------------- | :-------------------- | :---------------------------------------------------------------------------------- |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address) |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed               |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                           |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low), but a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.11","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.0","dependencies":{"qs":"^6.9.6","ws":"^7.4.3","mem":"^8.0.0","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.3.12","eventemitter3":"^4.0.7","@babel/runtime":"^7.12.18","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.0.12","@ethersproject/web":"^5.0.13","streamr-test-utils":"^1.3.1","@ethersproject/sha2":"^5.0.8","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.0.10","@ethersproject/wallet":"^5.0.11","node-abort-controller":"^1.1.0","@babel/runtime-corejs3":"^7.12.18","@ethersproject/address":"^5.0.10","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.0-beta.2","@ethersproject/bignumber":"^5.0.14","@ethersproject/contracts":"^5.0.11","@ethersproject/keccak256":"^5.0.8","@ethersproject/providers":"^5.0.23","@ethersproject/transactions":"^5.0.10"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^5.1.3","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.20.0","ethers":"^5.0.31","core-js":"^3.9.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.1","typedoc":"^0.20.30","webpack":"^5.23.0","@types/qs":"^6.9.5","@types/ws":"^7.4.0","benchmark":"^2.1.4","ts-loader":"^8.0.17","@babel/cli":"^7.12.17","nightwatch":"^1.5.1","typescript":"^4.2.3","@babel/core":"^7.12.17","@types/jest":"^26.0.20","@types/node":"^14.14.31","@types/uuid":"^8.3.0","geckodriver":"^1.22.1","jest-circus":"^26.6.3","webpack-cli":"^4.5.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.10","babel-loader":"^8.2.2","chromedriver":"^88.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.0.1","@tsconfig/node12":"^1.0.0","@babel/preset-env":"^7.12.17","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.8","crypto-browserify":"^3.12.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.0","@babel/preset-typescript":"^7.12.17","@typescript-eslint/parser":"^4.17.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.12.13","@babel/plugin-transform-runtime":"^7.12.17","@commitlint/config-conventional":"^12.0.1","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.17.0","@babel/plugin-proposal-class-properties":"^7.12.13","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.12.13"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.3.0-beta.0_1618413006421_0.17343943924882543","host":"s3://npm-registry-packages"}},"5.3.0-alpha.3":{"name":"streamr-client","version":"5.3.0-alpha.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.3.0-alpha.3","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c472654e67a008c69d72633192b9baca9969b88e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.3.0-alpha.3.tgz","fileCount":98,"integrity":"sha512-8Ka+J+FG4/EzHGFiqwIuzpIIyqpFajxE+oxYxgdPeHIX9yelrFUNzgFoupqNjuax1GNiSRuyXjRscBeXQBYzUw==","signatures":[{"sig":"MEUCIEHV42X/QdGVJz81NedWDkzuhyVtSmSk5u2sDhVWTtA5AiEArABtO8X6ojtX8MfiaRKtX29xjMtU0Kv0cnjy1qjjW5k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13308752,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkm3lCRA9TVsSAnZWagAAVi0P/jPozXDe50091r0Zm6PD\nRfV0tk75RfCxvvW3GB/uIYYWdZ3fEvK1eW///kHDaswodURifZLhb2jp0Bcs\nO+OqSaBTkTxDZyOTXCMqdJXJRony8dy8uhVrT9jRaggkVCMJM37xdd7eUfZg\n0gZQDSe2n38lna0LzRVPmg0FxtNbY0kB4+Yr/WEQnTUb52JbdyjPZrPxLKVk\nSmSA9RH4WiCGRAyS1t/7mTyfmIA0NV1AmdolELEbosbRafjqTLPKdRbhseJQ\nUzRJ0HS+2CRTsboW4N9Dx2qb02uUIbuQyKgkpo4p5LS79ykD5naTYl3GvH1V\nSB1ijdfbgFhnhjI50rmHU558Blenc0rIrHJnbT8CWOOjni8tsA69Eg87gw8A\nG4xLbulqQ63/Co3XygjsgGQRuP5dJ4RCMk0QRysFMkp/iGwTqoAVE+I43+m9\niFz//1F3QbspKL8sXojGuRmdt0zJCV7nfq39e/gVJrhqK486AX6m8r5ElbBc\n6hWJAH2FghyfhVywPQNeoJ9guXXhQ6joPIWG0wkedPXDom96/zOWUfHHknjR\nuEZo7fwIFbrgRecGg01/pb2Lz90gsXp+to3NzGzUQ6xaxllcLd6JTbRyv8Tl\nYVURd3D9LkWL0AyFIarSpLEmcQa4XSMAPRgGZq3x4vbTcGGuo9zALVkW/4Sp\nb4mZ\r\n=4LsH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.getOrCreateStream({\n    name: 'My awesome stream created via the API',\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). |\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case. \n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                           |\n| :---------------- | :-------------------- | :----------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)   |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge |\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                 |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                             |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.15.1","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","p-limit":"^3.1.0","p-queue":"^6.6.2","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.13.17","utf-8-validate":"^5.0.4","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","streamr-test-utils":"^1.3.2","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^1.2.1","@babel/runtime-corejs3":"^7.13.17","@ethersproject/address":"^5.1.0","webpack-node-externals":"^2.5.2","streamr-client-protocol":"^8.0.2","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^5.2.0","sinon":"^9.2.4","buffer":"^6.0.3","eslint":"^7.25.0","ethers":"^5.1.4","core-js":"^3.11.0","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.5","typedoc":"^0.20.36","webpack":"^5.36.0","@types/qs":"^6.9.6","@types/ws":"^7.4.2","benchmark":"^2.1.4","ts-loader":"^8.2.0","@babel/cli":"^7.13.16","nightwatch":"^1.6.3","typescript":"^4.2.4","@babel/core":"^7.13.16","@types/jest":"^26.0.23","@types/node":"^14.14.43","@types/uuid":"^8.3.0","geckodriver":"^1.22.3","jest-circus":"^26.6.3","webpack-cli":"^4.6.0","@types/debug":"^4.1.5","@types/sinon":"^9.0.11","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.1.1","@tsconfig/node12":"^1.0.7","@babel/preset-env":"^7.13.15","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-promise":"^4.3.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.1","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.1","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.22.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^3.0.6","eslint-config-streamr-nodejs":"^1.3.0","@babel/plugin-transform-classes":"^7.13.0","@babel/plugin-transform-runtime":"^7.13.15","@commitlint/config-conventional":"^12.1.1","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.22.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.13.8"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.3.0-alpha.3_1620209124574_0.175963321108217","host":"s3://npm-registry-packages"}},"5.4.0":{"name":"streamr-client","version":"5.4.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.0","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2c031604c37f845d5b28009e39c499a9f758cae3","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.0.tgz","fileCount":66,"integrity":"sha512-EErlmG3mPICxYl0R/UCrjeD/1iTrrTf8Y14BfFCgIYAVG1qP2odlNU78EyVskB6jkYNX81RLqyz4AFv4zHwy1g==","signatures":[{"sig":"MEUCIDxIFviU/QzTlHyo9wF4fGEm3ikWTfR6q9Dlw1Ji0CywAiEA3lrm9f16wR8HdPvhB4fhqDtdS33ZrHHK+PRHT7IwfL8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13367167,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgpw71CRA9TVsSAnZWagAAGVgP/ifBwodjMiEDSLSSlGuQ\nJVghKzk59g8rTpx6bMTpzF5uf+mkuz5oBVl3vV5p7RvJMOeEzFseo0iehV7P\nHUXYFiPAelpU9kL6I393t3FG3wc3fMO6ZwxYemGwGwWSIqsCkxinc8SnZLcs\nQ8Qx9T7Fgwy6jQccb22rDZUWZFRTL8PsbBmEGUlb1mTLFY/P1Hj/LH90Xox9\nOOTyQLQZyJwzOJMqZmAW7LOJeP8e6VpBnxqxrz8Gcc26ZNtKTB7elz1Hr8HB\nUTLu+6vRvaGUDHP+AWZzgbNgkZf47BfRjic5s4M4GqJ2CdfbH7VVwpd5Vzq8\nr2pikvtSRGk+p67iDOzq7lQgLnaJkd9anonJHs+GpYmCOUdmVLkyTaKbTieo\nGujeoCDQ/pkkdnafkpZ5pcOH1/th+Gk26EMhBQhXuMyAukGF/w36zfgH3fr9\nUBl2DmDpym8bGdzunc9WQo4yXYb8p7smpj6VsY7WAmrDch2WdBtNbZCmnUJu\n8SuLW0pfar403uCTGs2o89JWVQmIqFxRH8ecxtAgCMbhcXgTAeyLlPzJQ67E\nxIVBylZ4mIvX0H873VAReWj+NRBkoIUU8A8jlyGdOyA2Wuv0Z+YCYZzFquir\nc1pC6eibHY6suS+HRtaqVpEHcgolhD3UKttS9bzpzkBJWwwcONZKx1Nn4DGX\n67Ze\r\n=NdKX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This build is missing files in the node build. Use 5.4.1.","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.13","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.1","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","streamr-test-utils":"^1.3.2","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.0.5","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^6.0.0","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/node":"^15.3.0","@types/uuid":"^8.3.0","geckodriver":"^2.0.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.1.4","@tsconfig/node12":"^1.0.7","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","@commitlint/config-conventional":"^12.1.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.0_1621561076526_0.8514393351108642","host":"s3://npm-registry-packages"}},"5.4.1":{"name":"streamr-client","version":"5.4.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.1","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e7e556eacfef10844ef74deaa067d7323eba8232","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.1.tgz","fileCount":156,"integrity":"sha512-PKiRpYBo0KSWuCHM0xPcX2dcAaIgFzNsHYUK0DWDPWEq/WNanxUUYGb/7/JzXmbodm5FCiFalekwnK5F08BKpw==","signatures":[{"sig":"MEUCIQCJJhpJaZKDgf5lol5jaMY9KyKPMEgoIPNNscB2CY14ZwIgbC623mqpbGjsIzhvbxIbcyKql0Q/12Wzk4HMazYTXFk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13863582,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgp8DNCRA9TVsSAnZWagAAHTIQAI6UXLwqGqVep5TBV0h1\nkRSqJUicgrv3c1F7vHaPtfqJk2ewW0ef0qIuFUaawq56uoE/+auY3vqyMBVL\n6ncreh8DHZBIPvI3btU+khoqvTdo25zqHNez1kBpjjxSSqQ+nxePbkMOWrwk\nMBsdNLiz/9YMDpKM1dAKBH6kAH2TQ08JUMllX+zBuroy+tgDwm/Il+7qYVPJ\nnbzhN8kXed6eZHf+jjMXbIJ2v0+Qwv9Z79TXHPqu9AHpoDzDrDRVvlVsv4WH\nBm6RzKNy0/yqiWbju94yEjDCKGUprl33Ls3K0bSfUgH5/RFW2imXyIE+9j5O\nnIvk2xe3cGvDuN3ghlUeAA1ptMFAp18oTJ+X1kwA2Kenra4jBQcs649Se3G1\n3UGUMv1IvBxDZKHPB5UCxD3+ltJetOsmILFMtM/j8O3zi0uWzjPHARy4+pHQ\nzgNVTMmAOeF+BHx0NKAGaeIY0M9jOfty5/xSusozri53beMvNuhO/pUumqk1\n4DLYzJymtldvV90xBtLnbDicuBioI3cP0d6ifPvVJkQgnn02IuyiydU52e6H\nM6nypeIqwmSLUf9eaggg/7capeZeSYfX79Jlu9J0V+eeQuo2ll/MUhMUXYgv\nCqEFVemEJJ+hpL6uRb/k9ZYWAIx/1rg7iL52csYixBa+Ymo7mc++Ty5obzLY\nDTa+\r\n=olBC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.13","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.16.1","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","streamr-test-utils":"^1.3.2","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.0.5","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^6.0.0","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/node":"^15.3.0","@types/uuid":"^8.3.0","geckodriver":"^2.0.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.1.4","@tsconfig/node12":"^1.0.7","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","@commitlint/config-conventional":"^12.1.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.1_1621606604954_0.6253652879372003","host":"s3://npm-registry-packages"}},"5.4.1-alpha.1":{"name":"streamr-client","version":"5.4.1-alpha.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.1-alpha.1","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"6a4068c6a2a49796d93e36457dbdf2dfa5f81f58","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.1-alpha.1.tgz","fileCount":156,"integrity":"sha512-6EjNvM5zVxF/c9bexLo/xITC6TS3Hy+s3NNXXGYFHky9795EiFsFXX0jwhyeJXO+cAnegyfWc3uidD4JZQD0uA==","signatures":[{"sig":"MEQCIAv+nZXjdtLAw+GbThV1kCxSN8eD+8lgWWGvSyk9jZlHAiBGtV76G4LifVqn7DcQxrYY6X+OL5MLfkepMcQY1iiPbw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13869401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrk5OCRA9TVsSAnZWagAAWnoP/3k1R6sFLOi3J4DnSQUc\nQyV7S76UIm/xl9UkD+Gh/Zvo6Gt+u2DdNolLVIjSY00A+ET9z4YBMaMVPU1p\nf6VG3/L4aeraSOzbfe2WZgQBrw9mc9koNFkAOQ1jEBBGSTjGeI+o+5a7S5+/\n3NMAL9zY5CMDvyQD5VAighBJPkN4jd5JFGbv92GclYTHTMFp3X3yLfp1e2sa\nkOXI91eStjEbp0/V2GwoZdLk2ndBBUqhPYBzB8NKFVIj7d2NMj0kpt1ERI1m\nfuT/WtxuqFnQaHr5YsyJSB71hZ7DkzFIQzErwHODnavVzb3QLsdmc48I5VEg\ntZ7YQ4GsUpoUzbow8pboZdkOXOOZx/cN9i4NWjmNkfLAN6R4K0tjA7YyPaB6\nzxtK3z6rrK/8FYyP5WoHkdfL3q3Zah3LQeDGmKGXPq+16HltqJDyMt/e17j5\nD2S+ahppm5v1mWcASaq1cAR8uz9IB/prHfDiPT/KdLgMPxFpLKPEK1FaZvEY\nDgJLCbfCPrvkY3zfozKNMJOeNwIS7g6QxURPdWAUVMRORrMBn9AnpheBKBPg\nXmE2QBSc5vAFFbp5fLoyddZzM1S5ve2OZi39J+gpJMrB5iRTIRDfl72h98PN\n3gh+wbMYmq877KrEveTNYq9Jl5LH/NwFiDCYHyw6zWjjiKxLpNW8awSxsfIc\n8XX7\r\n=O0xo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-etherereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case. \n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                           |\n| :---------------- | :-------------------- | :----------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)   |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge |\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                 |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                             |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"12.20.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","streamr-test-utils":"^1.3.2","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.0.5","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^6.0.0","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/node":"^15.3.0","@types/uuid":"^8.3.0","geckodriver":"^2.0.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.1.4","@tsconfig/node12":"^1.0.7","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","@commitlint/config-conventional":"^12.1.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.1-alpha.1_1622036045858_0.26014596836792525","host":"s3://npm-registry-packages"}},"5.4.1-alpha.2":{"name":"streamr-client","version":"5.4.1-alpha.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.1-alpha.2","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b4c092af5c8cbc4ed99654ec62291fc8784ea8c5","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.1-alpha.2.tgz","fileCount":156,"integrity":"sha512-1rs+O5CDuWfnJKVs6+cDxHDzcBY7vpFhCTBHa4bMOH/Yx3GDYU7IENLXXOqA0ahIX/k+2XMhbeJ2WxX3PuV84Q==","signatures":[{"sig":"MEYCIQC4RkCfFlgXtSEj5eR/HxqKQV58YhuFMAYewNlr9tw1OwIhAObn52dWlX7hgoR2e7A6OocX+elI73ZtN1E4SgZK0CLv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13869453,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrlORCRA9TVsSAnZWagAANPYQAIQh2zDIUscQaeTYbgnm\nVec0eG3InoGq+6A7sY5EJAJU7xAEhLJcW+y3JJ/h/ziKg9z3MQF9WfyY0tA6\nm0baE7ec48J9I9y5APoAHVTWHr6FH5ASOOc4u6U5PEYTTeNs2fakFrWOL9qO\nLws4jqiKtcumqXERnboIW6hrpFFtl0DB1ll/7v3XD2sRQzwfSqF91OFALx3R\nKTljRtfzJU6p0CCkjNvIIXqeaOskEpedSAyhgfQrF9ej8YFN7xEddoyT+q5R\nxNZ+Pfle/UeEZqUfdvuN1sNXH/LdgsKN5GJmVdvbR7vcUcnvSIEmIHh/9VNx\nHVjkGZnPJARRqg4qsEKIXwoA27oJlrhRNjH6kZ3A9Yq8iJMBXnV7Mae/4LkP\n4+Ls1O6ku2nzqKa0xJ69rTqc0os9Rcn9glUrL3c/E8hNF4gCSWYe9vwgf3k6\nP9N4ZZcCqZoTY1b71nt5bAPCByu3xOQvm0rpr0AQa17y44zKBPAwHr0B6T1v\nzPQrl3jcvEfM21DCpzLk5ZQCZfnAWaxCOi/+vXvNCJOti18xN97+uCfSGV1u\nq9XWJ+b6nlb2i3ZG4xQdyJI8OM89TfYdRpEKszzMBHcvx0jH5A/vhj5X8OcM\n6XeOt3EA7YnEs6e4fOkz9YweEPLURSxuliifPZZUeVcJnz6/xH5/4ig20YHb\nY9VM\r\n=MYnL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/streamr-client-javascript/master/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Date TBD: Support for unsigned data will be dropped.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\n(Authenticating with a pre-existing session token, for internal use by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-etherereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case. \n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                           |\n| :---------------- | :-------------------- | :----------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)   |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge |\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                 |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                             |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.8","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"12.20.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","streamr-test-utils":"^1.3.2","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.0.5","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","husky":"^6.0.0","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/node":"^15.3.0","@types/uuid":"^8.3.0","geckodriver":"^2.0.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@commitlint/cli":"^12.1.4","@tsconfig/node12":"^1.0.7","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","@commitlint/config-conventional":"^12.1.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.1-alpha.2_1622037392824_0.8572106118026308","host":"s3://npm-registry-packages"}},"5.4.2":{"name":"streamr-client","version":"5.4.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.2","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"edc2ac0d39304e104ee9c3712c66b855c3f8f222","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.2.tgz","fileCount":176,"integrity":"sha512-o1vtZuaHH2sCfdYhIcTkylNNx61u3wpMCj8FeN29MkSucp5/urAxU/i3ytj3W8ZMRD9sPNsdI5D50CVRimDIKQ==","signatures":[{"sig":"MEUCIQC8tNc/lKSWEZAejgHz3LcaNEuDqo+XdaDYKzCPYAatbgIgIUCKM7ZNp9lwkeAVj9l+tAcboc7RnqP2lp+Q/BFBEpU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9812210,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgum/qCRA9TVsSAnZWagAAAxYQAIjncmRagaD6Kk98xfm/\n+B7KAy0XsKQiLKXzlEsPtwnjaqYZm2cLkt35PKyto6zwzMmJHTkgINl4dnHy\nDEGE9T2/v1noq57PPZrIPGcel7orio8Yyg8iG6n20GLGVrJdg0C92z/XooLM\nPmBBf3qMnzuuqj1B7DSyIqS/NEmOgcyJHHlzj/4a2txd9Bf1QEQvTZRRndGT\nOWsZ3aYuF0OqPFvgWaqKcbbl/3JV6Ui6rVqO/EcqA09neG/1fgqDuQ9GVLA0\nUE8W3NkM1p4//fQgLI40JHvb9bkp+QT9M/ZgRJ4iITqnqhKpBx1/avy8avRy\n1yqiIhPqPaSknq59IOkWgM/xYLhDwpNvWt7T8PA99U0xSYIaUHmoJBmdYL+v\nMjtc0bR6eWwRNYcmjQeoxG95w0/gk0lObHml8XyoullDyV0E6Pq4bVPJqlbV\nC+ps6q/3mcTtvOhghwzxrDuTCUbvu0JJ4AaWmNIq3A1TFpKcdIU1rYwyVMeV\n44B4ibQizsqhnUd3rB79XCP0AtUmHY3YUmK6ndCg1EZRe9dw71zsD2GdlUC7\npwKzeYCooXoSpOkEYDCEIQ6UgRffq0LRsYUhZDa1fqmIBN6eGHIihZsx6q2E\n5AXyQRqdk+Db6sEkvlvEns76tgu6BFupsRs9wjpx79GzbQ5CrM4/BtSfjK5V\nBW9A\r\n=AWKr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.12","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"12.22.1","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.2","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.2.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","streamr-test-utils":"^1.3.3","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.2_1622831082510_0.584665750727599","host":"s3://npm-registry-packages"}},"5.4.3":{"name":"streamr-client","version":"5.4.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.3","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"4151bc5ce790226f90785b2e81d211656fe4de46","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.3.tgz","fileCount":181,"integrity":"sha512-JvoK1qaZfxU2FkKWIe7LZn/FU1jefp5z3bclINkcTUCulNthASqonHRK5FCnyYQH3Ojr/tDBipFVZLhlmktnzA==","signatures":[{"sig":"MEYCIQD9Yb/Wf4q0ORyZyz7x7qAgRAC2ShkUXNWiX95PsBDJLQIhAPmsmqrjFu3OjpicUPccCU8rPQY+1aY65ZL2J9zUL6oA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13238670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgy15mCRA9TVsSAnZWagAAL7QP/37BF6zodVS/wkq9TWuD\nA0yundqEKDGtWsIW0Efg9ckDCmjkbWIrhx31csrCyjsQ2MEPpCFi7kdwFAQo\nIVdFRFM6+gU69/+oTYlJ1SHyrxMSnFCKRYFt19uuk51LkMlJz/8LoqE03ero\nP/XxkWiknAayPzFl1A2YsD/INpZpbE4LPn3j0nbmCEBUBHTdkzCC5AYpVHSx\n/p8kBw27DbdChy3E+j2iXCVrQERAA+u4VJhI8fgt8bmDewOAOVjRCya5AJOw\nUjsRjOhtwZtEZyYtIfC8ThHn+WRgTMKqA+QiUDnPuLR5/jhYzn0bWADxDlLs\nvalKeuoi8eh1RNlARV/ryb9q8RjTZ7GfZF3ziEfX0DeRhzQDvEQakzPyH2MU\n/O5rEgyfC61pZXp8gnU86Jvt1YXJgVY60NpCb3XZn13zg2g5eLK1rAjYoX+E\nTLkGVjuf1u4vJxkLtzqrgJyY9E8CMJmRxXNKu643zXXdgJWk/aHwDRG3LUlR\nyNvzhZEQiyaLk94GiyH3XBzgkIteV02meZd9OZe7Ikcat6KZKdOuwgKkeO+a\npHuMNuJOgFySFuIAvgZVdy8TUplDOIpUW+jlul2F3oWbfXPvNeRDrp+hRBAb\ntT/PT7TI1ZRjCJN97hRGV5xBg2cNqXBEd7Ff5B/6eQDfq7mHwihBuj/oAN6V\nPTyc\r\n=mxFq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.13","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.3.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.2.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^1.3.3","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.3_1623940709700_0.8121958240431053","host":"s3://npm-registry-packages"}},"5.4.4":{"name":"streamr-client","version":"5.4.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.4","maintainers":[{"name":"simppafi","email":"simo.santavirta@gmail.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"341d43eb7e3c292e1b50f5c5b3b01ad660af8b91","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.4.tgz","fileCount":181,"integrity":"sha512-MX9nWHv9esDvLUVAhVgQp5uNdMPr8jLydJgywNlgWqo1l9a0ImLYbTEVRJSvWmMFOFn0dHwmEcd/yuUjSaCL0g==","signatures":[{"sig":"MEUCIEs3jY1fD649imEwImaSXX39U2F/h4j95f/sHRSdmfA3AiEAsqxoohtt/6ZgFPvyp/zKjCXWTDqNrNUYhQLjRjRJyoo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13254520,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgy8PICRA9TVsSAnZWagAAcmgP/j/cFQVnNoX1FJwcWW04\nImp0j41fz0psznzcDenDZd1PYsfks1uLQ/LWGHixUCe28QEm/r8knHBIHKaV\n19FSM9JbSJYE2LmJ1IUslNTNC/1Zqja+l1/LlLhI4jfjUsyspqt0MtN13TnP\nwUsICPvXbH6k/fgOeIvhxAsLni3Ayeo9/0qUB7vfWrTPdXNtEluflwYkXZTA\nzaxrMOJeGwmf5O7+3UTHmRVOAiuHuTjJXUk5D/SCQBPh3q33sHsDthEKYIYX\nSI+vp80GkXU9DEtEc9f8i0tXFZpEyUXBtGdpA35Psu2GpoLnbAgEzNkEu926\nj8QGgJsQO8UScDAaI4mp1OQf7GAAYj/d7BxiRertHoheCmSG5pafvu1tyQhb\nl4s4OvCN/yUK/aUQ6hN0631Hs0179ATQsVbapk+JAJF50gYpb65fV7PiZWZ1\n8dBjE8HPqhHrs5ylzA3d7tbJfwPGRxOTroOIkjk++CmUa1WE/bYUWsc5pW4a\nBvU0j+BqvaP0jv2dDqg3jD8SRTEzIKHc9f0g7ehm3v+9qYwSeYsemdyqMaS0\nA6h/uSIaxvfAEz4Xei9bKd2kkXdDDdELr89L0/ZKf725MheVERHzkXI4hcNm\nYZmvDcGoOXGiu/+mYLvDjtHVkk6nEpAOvGnuA0KnUVBCCMcJufH5DJFCZat3\nqpAG\r\n=Od3x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git://github.com/streamr-dev/streamr-client.git","type":"git"},"_npmVersion":"6.14.13","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.3.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.2.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^90.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^1.3.3","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.4_1623966663606_0.3324367887114048","host":"s3://npm-registry-packages"}},"6.0.0-alpha.0":{"name":"streamr-client","version":"6.0.0-alpha.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.0","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"8b87f3cd84b3a07206bd126ff26f4f7d804e8ccd","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.0.tgz","fileCount":197,"integrity":"sha512-WltWNKvM4KgAyN7jEDa+9sdQsxBCk5AgmSjy7CBN2UDtEusN2DEGi3auxV/nxMbDaCSDXG6+i0dInRPMB08uKQ==","signatures":[{"sig":"MEUCIHCBMTxgY+zBUBW8AQrIaPXpLqtbPl0xQqkd3WEFSH26AiEA5+fuMPiu2NGQiWdCKOpFYeUAzqdAS9EjSWcO0xo57g0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":963695,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhN85+CRA9TVsSAnZWagAAy5gQAIQEwhqmcuRJzJaZi2nQ\neMSbCQRdKAQhWak/dndV360s1NIjzd+l6JbXm1dS1awmtURroxysRBQ0BS9w\n1deWZ28To0o9sgAzrTjAWl5ibiRyVb2rpSBV3dx+R7laOl7bJNDGjlBEc2UZ\nI0fW87L7rTNN25aDsIsINMEShKNeuCtAhEhfumJ2MNZ3+3EgsDqGZAeHIp6t\ntYrbTX5nT5IbXK2Ks/MbrnKY6P2+Wi7B74ySvxj9tyLpgQkYfKtcS7rFfsCx\nyFPAT76bLGp6oQmPhbvMlk0Y+ZwhY8x5rBk1/TpqSdOTL/hng+C1VVwCD9Y7\nmNX5vjpFQ3N0mp2a7ueGK/j3JNMrrIfHBtzuuzzf446jvafQnexqlpV5UJHc\nJQMK6m42F5pJfvYCjvJ90xVUOVBGoVeAG7/97w8/cZpsiTl8+7egNMQBBU2I\nFVgH/BfVhkQKI3X2NjxKSGLQZy8uTKiN2/l/m0DWFYMvrOE2VsHeKt9fOL0e\nm3eCVys98OQAnZO4cQhR6TWYuufsvWD/rM3zXAv1mWHvSrgg0V7E8xVsMN91\nVcSyotW2nUxNt4NQ/NUdvAj5Xsm5HX5Pp0dtF4aZXQU/jce9BBK5Qy4xhjXU\n/i/zdmDqqIBq5NAR4Tc1emF7XUZP8VZRCrQFH0uq9ncKA76cO05KW2jhomzX\nAhiV\r\n=e91K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This build is misconfigured. Use 6.0.0-alpha.1.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^28.2.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.5.0-alpha.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.0_1631047293892_0.2922823753813373","host":"s3://npm-registry-packages"}},"6.0.0-alpha.1":{"name":"streamr-client","version":"6.0.0-alpha.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"6d80ad2845a80dd1cc3c335bca863fe37bbff526","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.1.tgz","fileCount":197,"integrity":"sha512-QRT+WzeujEEt7Wu+bg2siQbj4Wj0vQLBliSltMVJgEfLBqHCcWivZjTZUfaPD8OQH/YmsNJV8oEUAU/ZtDA/QA==","signatures":[{"sig":"MEYCIQDuMOFax3Rs7kDirF856lcDA2Fx2jOhIGvb2ObM6NBGcgIhAMuwnnaYsbCVuD53QI8yq8qplbwR8BUtksj64OOmOQtg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":963705,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhN9HzCRA9TVsSAnZWagAAZrUP/Aik4TVA5kNhTMt7Bd11\nAQ5cUqKS7/FQ83IzPPEE+OjUNfinqpb8C4cBfZdxAAlZox2HvbktiDYGEJGi\nBAXtdBCh/jQ5IvsOpcY9q0KL+d4eQnKzGklCuiBMlE8QgAZLZMc1CsxQ8dv4\n6KoBFqiCNpLT8zLc5aXmAC1lmM2/TTfJTmJp++MWkIyR73E5cnbfmWN78g3s\nHh0qCaZjHwwNf2K8PMAW6RwWXwBXw3svZLXHSFVHq7RtInJ6vpzCvMBBbPbR\nUnLZi53c3VAZ27ZyNonX9D3/lQnLlaGh0mLOmxeHreNeUZ/N+xvP1sqKe06S\nbTyiPTlGFUI87wZuQyBvwByl1dqhY932X/xKeXwLn+WUDfppEneSQkXbpqj3\nD69qWiTzJlYJXxT8/v3XP+WbH0AB2nXm9sf5lQqt3dmhk3Ai0JkR6f/0MEVv\nceRMxOACViHm2uQOfIqG7+pUoLGKjMvdd4jLXn8n03e1j7c0cWHIxBMRITQs\ny1S1qcgWeBwnrgLt6r4cBdi79uUNYZ0CUZs0E2nhxNJDuoUJxBrAmqmPc97G\nEcxG6uQXw9nUJ6xJR8TjOG+YKeZFBRpfxbL0EN+18MteyniSrVjYwSYhYVlR\nrcz4jaIQgJID9S6qSO78yhwrnIT0LIM6bjKtKQ/UIVno/evD3BBPPieYb5o0\nWXT7\r\n=hi0e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This build is deprecated. Use latest alpha.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^28.2.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.5.0-alpha.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.1_1631048179391_0.4602883245921252","host":"s3://npm-registry-packages"}},"6.0.0-alpha.2":{"name":"streamr-client","version":"6.0.0-alpha.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3b5a961c574c93d6195c295909f410a1758f3b26","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.2.tgz","fileCount":197,"integrity":"sha512-b3o8CvNbPbbMZ3ck9hniXeLSwWBjB0nF0wENqsmR7XdjVJChJnMXLUg3gT1nINevveUeyPzV6KxTTtXQetHYNA==","signatures":[{"sig":"MEYCIQDNMQIpjN4qqseIR02HCYprZNwEfitns3EbFSzA0GlfHQIhAKDqNFBMXkzJnSltInCVBVN4jqPpERrKBaKo4KfZc2a5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":963348,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhOJxnCRA9TVsSAnZWagAAG34P/3OpCSi/ZNqfhMFp0OFc\n6NWkDvRAT3+KqkDSppZu0D7TJVUDs8aWcNPeVUI9OmHGM2/jNF+nqVWEogyj\nuoT5UJdowqdEMkWU97ANZlY/BZ60sVNQx3vTAD0Z2CTxkSevcGjz3IGIkHIn\n74jsxIRilj8brYZ4B0Dfn6tGhv/jfhs4yM0lJCMQj6O1XlBvLlj90zm5cbtd\n0U9r3HERxFwFKqPmooFbU680hUqHgwCunZ7ReiN+EIiDQEsOkEA/c6tC6y28\nkuLLoYVrwpCE9AhOCvVADmoM0FYyIvBZwJVLcNGMgrd/JL0MnW5hQjoK98mu\nWUUJT5yyNXcB0N7Splb0/cqZklpasoxSEoN5N8ZHtCvYge8VMXvHNcmqE4G8\nB1ae8uXdhPzX8VKa6xSLrjwhht3ZJefXHby/wIDEU6iATvUxjl0ORAjzWV92\nFz9P+1IPMGe9GezDRX8+9TSrhi3+HiiwoZr7pDzWcK4n5aTfUTk/2dNpYMta\npPFyTVdCZG6lH+eXcIBMquKywg+nkP1ZVtD9GHwRPX/cVe7rpkC66JGEvRZ+\neTddWLOxDFQRKgpCro+BnA54MznqDs3K+IKMhT52KIGo/QDSDahho8fXkU3A\n/0LpAMcaQVvHCHMhq9FC2qY78aD79Tb8xsBfqmC/fhtrigVDSnBNMisJqrjr\ndNiC\r\n=mQn+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This build is deprecated. Use latest alpha.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^28.2.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.5.0-alpha.1","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.2_1631100007607_0.8102192325071063","host":"s3://npm-registry-packages"}},"6.0.0-alpha.3":{"name":"streamr-client","version":"6.0.0-alpha.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"08d10afef300209265104612413eadad540ec2bf","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.3.tgz","fileCount":209,"integrity":"sha512-T5LNedk+zWu/FOKBkA3Hls8Rt/zit5GkIg+XtNlWXfDePn3uVuRcCe8Wdu1P1Fwm2WZV+p0Uqo7BBVWiT7vm0w==","signatures":[{"sig":"MEQCIEk0ptjZlhLZpejVlRCr8qBhAIcyJMiOcEAMHubRbdEUAiB6tI65HTXnHoMq5DlDxWTDLwmQXdDGTTgnmGhcpe+M4A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1103405,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhOgaJCRA9TVsSAnZWagAAkLUP/j/dJsZb6kiPXknKO5fO\nj6nhLHx3xrzaHT19DMr/Wua4oYj0hhkS57EOuiA1Il1dS7Znim6Rt+iveXTT\nuqS+zoDwDTlUDJljj8ODkpF1WzOX8tJuEL21HZipjJ1BGYvw8yt1cW2xfPo2\nEu+LwraYkVPyvQ5wV0aoK5TDPMhV5deyIkLTKTIbyM0N3XxsfmUqHBe0M6f+\nuaVqDq3z2AEm7ErxqFMhwyA++UnLUrQR4bcDhp4W8/3Og3loQHCrqmWSpHUV\nNd+aVPQONeapTflxoADXDqrtgcDzR7wWvY9PlW2YfPWE5ZCB1HCWHTxqrwaW\nqQAkBOPxe5fqASzr3HnpKtyXuZPVCWXZRxOG21R3pw4oRR1vYSxOuNVbaVxX\ncOJInP7Mdf79vSdKl8XT4aVXvjhNn5bTFPlib10Kgk6bmfnCCw8QRaz6ccUc\noDvKpLlR7QRHN1bTgB6f+DZDCueTlimH5RC18KdbKY4xu8zy2HItH/y/EffY\nyNyxTkQskl/a2l7rZ1ra4G/16cCkXu1DdSD3jahI+tWOgq+g0a5l2dtLi2WM\nGQB1nOD5iYjMZvPGUW4xN8xCHOKUYZHPrIqaFzIyV7PtJEBVkzKs/3jcLIoS\nVNfZ7T896ElwIL4gMRYQ/a1Z9KlvuVXZ+hgwSmuucLd02FOIRxuGVSgwOnty\nJPS/\r\n=YSJU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This build is deprecated. Use latest alpha.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^28.2.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.5.0-alpha.1","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.3_1631192712861_0.47640032869963034","host":"s3://npm-registry-packages"}},"6.0.0-alpha.4":{"name":"streamr-client","version":"6.0.0-alpha.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"82d7cb02d30e1ed04809abaf3153d8f4fcd24f7a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.4.tgz","fileCount":209,"integrity":"sha512-Q8QRF007L9J588wSnGjRpKER2ViXwOPRe/xETurvACz7a9FX7NlwCrw6djx/ZeOsdheAGyulK8WI9AYbxUMmvg==","signatures":[{"sig":"MEUCIQDn/FvytQjGr+lABVRpjdt0P0NJwnBYOifdwBWXEqU3sgIgEqJ9KXD1gExig92IzIEQd2fsq5JIoMWDXYIDyI9MpHw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1111385,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhO8ZzCRA9TVsSAnZWagAA2eAQAILe4Forjg1vKotgeayW\nj/cOe1YoZcLjBjoA9VgJbCDgIL4PnNxLxTQ5f0CBtPlzjWJYAv7JVKZ/4uBj\nmMJJ+i+VUXuaaAypL4SzfEGm7zJgmVZVrVmlYej4xYVLsDgmzrQ3jNADi0tP\n+B0lW5JAMxGXBvM0xQaZWpH3VQZuELCCsS7Q1MsSbgIZv5P4B+dweo4xVitB\n6Y0acFzUGAUN/PUAR35v7ubStBLjVDp7pV7hqaOmzozWxyzC97HjPUXh0uI5\nW91Xs43GOvpBxej7t6b6/L68SBHb8UFJdfUPN5BrpsybEtFE/z4vQ5ePYVI7\nRLy9YEq0aip+jCc00D0ft/c7mP74kGKXKZLj6l4Ls6U3bSxDzPudLnOV9JzV\ngDDoHLRToV+z4nBDHOcG34UleaXS7TBgDxFTVMT+CS3I8Lz6pii55vqqdF0o\nbv5p+bDafLJ0CAvmxDNV0hreS22MKOgc0rGebgzDL72cMKk6nxC7i74gahrC\npA2Gp67BmUwus1Wwue4jtPU8XTW/W7ALCNuJpe+6U+TuPlPHke07DubMlqGw\nT8fnIHCzb+oxDwzofC+6nDeMahnpzlUaKucOqfGeN27CxuZzxUriiYSfs4r0\naXVYufbaxLehw2XACXY5EjA6kfVdWk6SMr61z0yx6IBc1+/aE4J8qE0KEzxk\n2kN0\r\n=FqTJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^28.2.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^8.5.0-alpha.1","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.4_1631307379051_0.1222985098993481","host":"s3://npm-registry-packages"}},"6.0.0-alpha.5":{"name":"streamr-client","version":"6.0.0-alpha.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"57ee0684038b723cd825af0de7fa1116485dfb40","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.5.tgz","fileCount":209,"integrity":"sha512-t9AvfvLf7gAI5lG+kWrztEwKV5Zs2Poz1GWTtVHRYa/QXJI+IsTUE6V9bM6D+LautBD4Bz3av4j40NM+gAP9tg==","signatures":[{"sig":"MEUCIF211YZlt/NNPd2Jk0PKDhtcScKzrVx7FPVBisQTRL0JAiEAmJ2cvqfFHZcJ/rDtas97lsg3gpIdUyhRM6xqEEW0myU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1117210,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQn/pCRA9TVsSAnZWagAAAcoQAIscRK3if59HdyNnjsMx\n3Xjm9DypnKl6/9mpAJKG73Y0vNZezsYSmJuSbn5T8iWCYQpxBM9d0wuBSCKo\nBCJSt9dzpZ8JRVyqHmeeV4d9k6IxJb4YvOlphX7wKhx5IAsohET8lvYZ9kI6\nha7vGelAm+Tud+OMKOMOJeY/X52vUj9Xy7tezhlqi0w2QhsP7iuJ/p2MJfod\nZ0zrhps36pEaRhE+MQ26+zF/oXjGP7XlculdXwqaQCASefOca/uH9SSb0QOu\nCWLoGAxH/EnuofZtXG4h9lofs6h75SqUCvfEgse8/BNWEw1fXg3dQEUcjcwI\nJtuv7BRUiBKeJR0/6BirPGkbQRvCEMYmndLtEUBFwAEEZcK+VmHEnCkBOUI1\nG8kSgoZelXBZx0eDrqbNltDgWqkMO0az6WfUSOwQnMzNc6/sBhDoTnHizTON\ntfWJ7lBPeP5qc8PLywc9igsoJZzU8KS5dl6madJlJ+L29Xwj362liSTiVQR1\n1va30ero1JIZHGSqSGqFICF0Jh7G0LbqPLGijFCv0d4L4P4glHbAeZk/rxi1\nHwE2MKgk8qsAtm5Yui7+yQxf3Hjz1DbdJcJZ16lXRlT8eM/ZYm5k3mTgWfkz\nKkwwrKdVk42npGP4MOafAQeQZAq5q6VGp6YxnXpr+ds/W43C2RqHhbVILDoT\n+ruk\r\n=x1j2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"This build is misconfigured.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^29.0.0-brubeck.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0-brubeck.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.5_1631748073137_0.3849618760773206","host":"s3://npm-registry-packages"}},"6.0.0-alpha.6":{"name":"streamr-client","version":"6.0.0-alpha.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.6","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a08e74bd491312cede4998e9cdd28ab142dedd74","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.6.tgz","fileCount":209,"integrity":"sha512-xSApYT9aaLIoFJbESDU0n+ke8yH9Asn3WClXBJoSHUvEeFMeoKnVsb/cRdQIxcPoYOfqY2GjzbYZ+069axfX4Q==","signatures":[{"sig":"MEUCIQCpeiI4hkJqHNr1+ZnoPp4nSaS4238Qkt9wX/PMMmaEFAIgHYmDphKmfcl9DJ7QYAUlSL0Vfd3+HQew/vu8YHSw+bI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1117210,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQpvpCRA9TVsSAnZWagAAiPIP/0wfS3fZ6+c1z4jzU65o\n7153Bz7p5c6JYAugiwsUkDBn82YnaJ49d+St39Av5//6OzRWVxhFpc+OV+DZ\nWmieEEoKNegPAfaKjc+GoIOhqAucSxga3WVfZTLcIKzKfAidg8vBX0dPlVAD\n2ngsd6s+rVczFAwYbIgf1AUwHT3lAIXJhcJWDXzITVRXE1FR2fIYkjc3ldv4\nkKKjbc9Kwoc1ALutVaZ0fHi/1WEy6f4UlPIyRQW+3qBaFS2Eik16AvQKLXre\nwp4H5+8VwGg/pATuiIJ6CYfIV1VI5Y9obMSEcuKeD4pGZnVZu5kz5GwcY2+a\nhNa8fbNmlFMgE0QIZHk/HomQf4aPH8zyA1MjMb5xHb21qFcYtlvLDIuxhSjD\ncRX29yK/d8cUf5VDjNV7ugPR2oACtpj11Ych1EZQaT1dBd2+j6KNzX/AAA5M\nVDtg9XwUQkAEa3bx4YnfoF/+F7TINE4ZMFkyFkkkgXsjrh4h11j6rb/CWHLH\njIyP6plYxCfrE/UsZ117msqo9vT3Rcqg1q9SQvXCX8VvxpvGN2fiUiz0+Gtt\nVC4/da8nxQc94g86EYacMCLeE3vdKowy20s3h8r88l1A28bGIqL2GcXyfMCZ\nt8313LJhHRjmZ06a6JCwNeAmLxiibu7C5C1qWopj5s3Q6CnJ+NIUf7CZtSjb\nEw/z\r\n=+ID0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.5.0","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","streamr-network":"^29.1.0-brubeck.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","@ethersproject/sha2":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0-brubeck.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","@sozialhelden/fetch-cache":"^1.1.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","@types/qs":"^6.9.6","@types/ws":"^7.4.5","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.6_1631755241098_0.5160358548174535","host":"s3://npm-registry-packages"}},"5.4.5":{"name":"streamr-client","version":"5.4.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.4.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c40986187c321cbab48c70b5c6df8c238135b932","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.4.5.tgz","fileCount":184,"integrity":"sha512-8+FG7ee8W5ktNbqnvcQh7rjuDU7Iw8DLuWOxo2gqDWkFLraTG9U/H+HqVkp3Il2FbV0dlO26ej86c3WY+zHYXw==","signatures":[{"sig":"MEUCICJmvoBXgzRCQgZBfnN93wZiKutwlzKKkZWD6c8C/ZifAiEAjJk5rxvb7jbGCvaSiS4fYT33jSDCexs6NZdnY3vrtIM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13866416},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.4.5_1632317819561_0.46833226663538063","host":"s3://npm-registry-packages"}},"6.0.0-alpha.7":{"name":"streamr-client","version":"6.0.0-alpha.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.7","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a97315579f169a91091f7b2505a65822ce9e81a1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.7.tgz","fileCount":212,"integrity":"sha512-Mc8LHZtjzjpLTgYNW5OQmP1VicLH67Lqbe79VNhCY4cxYn4D5yBtqIRgXHZcidTwSRCinbCIKwDFOndjYgQ1Vg==","signatures":[{"sig":"MEQCID5ZaE3CeeGDHjNAw1qHOmQE9cXXMONMx7BFdvngbrjuAiAryC9lGCe22PCnqLwwt14re8f+Vb+gXVfT++arQg+Y/Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1115665},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^29.1.0-brubeck.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0-brubeck.1","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.7_1633464759211_0.598420644884611","host":"s3://npm-registry-packages"}},"6.0.0-alpha.8":{"name":"streamr-client","version":"6.0.0-alpha.8","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.8","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9be7490962a98f9fa4893008e1951e44925efaf5","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.8.tgz","fileCount":212,"integrity":"sha512-lTEoD3yunm14pfS/h6PHctpVMmGClsTOtYBkPQ5oWrA4bLL7KqjClvmQcAByo6+LGyr6/xPqaSIcN6XM/OvxLg==","signatures":[{"sig":"MEUCIQDw5W8pGLHN5qMhnBWEuOtZXNc4OiUFId04y5qYNb6cTwIgHas08+NkLwgwYGqaRLb6lox3l3JU+1YnvW2kFE2wxco=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1115665},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^29.1.0-brubeck.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0-brubeck.1","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.8_1633516182954_0.8437763827506763","host":"s3://npm-registry-packages"}},"6.0.0-alpha.9":{"name":"streamr-client","version":"6.0.0-alpha.9","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.9","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1b9455005b7cf9218e7e24eb48c52b244738a583","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.9.tgz","fileCount":212,"integrity":"sha512-GY0wJoprsLYegoxpUYoNOoPcfh/Oc+bKSCvjzngkBsWG0sES51OW9RHPmOBLdkYc6zEHLrloPRsj7f66zs8XWQ==","signatures":[{"sig":"MEUCIEjf+gUl+wUdT2zKcNSpgL921Zz6okXvTcNWY+JWEhXEAiEAoeLR8fHLdyCVvq5y4kKgRSMyPSr5g5Y+0+FkwbIZfr8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1130695},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.0-alpha.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.9_1633613150018_0.7907119267412914","host":"s3://npm-registry-packages"}},"6.0.0-alpha.10":{"name":"streamr-client","version":"6.0.0-alpha.10","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.10","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3215ed6140f31b1852e9decae1101c755248828f","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.10.tgz","fileCount":212,"integrity":"sha512-uzscF7cBi91Cu0K2hcIr303dpTPvCT4/JONOEF/BTUZGCKXkNsH09HYIU+iqvfIpwPj3dJ/Fc6vnPhjzlzwaIA==","signatures":[{"sig":"MEQCIAgGW96YOBaK7rXwKPG4dVVhqSbE0ccG7FuxTg0lPiJ0AiAkkh3U3X3waWbEMgyw2pJCZE21CYXVGpbUK1dIFjr3hg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1130688},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.14","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.29.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.28.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.28.0","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.10_1633620996245_0.1309400550172688","host":"s3://npm-registry-packages"}},"6.0.0-alpha.11":{"name":"streamr-client","version":"6.0.0-alpha.11","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.11","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1b83605447d1c8d983e34f3fe16844235268f26e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.11.tgz","fileCount":212,"integrity":"sha512-XmdISPaxGZ8OfZ9lGWAJFFNUuDo5Abb/b6qDsTugbdqauG4toWzI0hPA0u65pG2Q9Os2gzfDix8XkTafS8rGeA==","signatures":[{"sig":"MEUCIFg3Sev8l5W11lZf6Y9wuaa65APQV4Zz2O08h1AhOjUzAiEA1NxWGp2Rd+XaYc5uZzQ9xq4d/qxMVxdFDPRd2lGwaes=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1130688},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.31.2","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.31.2","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.11_1633955999828_0.20169279016948138","host":"s3://npm-registry-packages"}},"6.0.0-alpha.12":{"name":"streamr-client","version":"6.0.0-alpha.12","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.12","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b39032fe011ae3440c8ac9df3e6e1c1c0c1b4a10","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.12.tgz","fileCount":231,"integrity":"sha512-fLuKf7MrHMzoZspLWuIZvpaZM1e/oX1SoqWMYKGmkWKRCBW1tTnRF681d3VjykXDVls2OLyJd/JboVqTktKgbA==","signatures":[{"sig":"MEQCICAXPX9DVhpE+UR+7k2qbsOLWP9z8DUrd2CwAs8JPrAtAiAOnzVyQqQn6FB3wA3RPIlEpaVNldvcD/kES1nl5vnh5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19407366},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","deprecated":"Please use streamr-client@6.0.0-alpha.13 and above.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^3.0.2","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.12_1634572684580_0.7277331443051913","host":"s3://npm-registry-packages"}},"6.0.0-alpha.13":{"name":"streamr-client","version":"6.0.0-alpha.13","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.13","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"08257309682e62fb50e6254703c2b9739b91289f","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.13.tgz","fileCount":231,"integrity":"sha512-Q96LWPwh4+EtTB8c3ZXWLQ5nwMi+o6aE+Aoe/49QPPjIfortoycI/RSNJgiouayeDcXyo6nUN0FrG/hWpLnHLg==","signatures":[{"sig":"MEUCIQCpBet2wFcQv7nso19tIjAwiKOEF2DMVWCJTjpVf4IHKgIgUd42TM83EO9NS+36xgGlOf7ji87xPG8EuGVTUkaLhLg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19416934},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^3.0.2","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.13_1634607059031_0.1990580452834949","host":"s3://npm-registry-packages"}},"6.0.0-alpha.14":{"name":"streamr-client","version":"6.0.0-alpha.14","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.14","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"8f94c1de0f3a6027a77a60f1d4d7f1eb7337aa20","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.14.tgz","fileCount":231,"integrity":"sha512-qVSVGEMdHdtz6bT3FG9AY9KPqC0zZcDY0X75eR0g2nBKfDFvz5JhdQqtXLT1b9fS6a28CAgbqY3+WnBAsvmU4Q==","signatures":[{"sig":"MEUCIDI4uLyu0VYDkH4juoQi9qhpn2fuxTQ0LRjXXLc95ULSAiEAtcONZGBg+MVVXZIVf9mVo3iq5yex2BURYm9rbbqXNVQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19929255},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^3.0.2","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.14_1634664927441_0.8017823803924597","host":"s3://npm-registry-packages"}},"6.0.0-alpha.15":{"name":"streamr-client","version":"6.0.0-alpha.15","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.15","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"387da65b602814052919d248f7b7bc5831cb4380","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.15.tgz","fileCount":231,"integrity":"sha512-fAlVa/v4hHJ+9vizZDE/W3H0JXnQw+60FrbYgm9hLuw0GND4R5/8aAQTzQB6nU/4kwdUUqzfSjSS/fVLKd/HNg==","signatures":[{"sig":"MEUCIH5PAMicGzGQojJYpQe2UYaKgsIBiNVzimi17Im8hGPpAiEAoeO1mrdSaO4oj/QLiBXLcbrrz9BoB00ShTi41jH4xUo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19930132},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^3.0.2","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.15_1634667167894_0.637476438892685","host":"s3://npm-registry-packages"}},"6.0.0-alpha.16":{"name":"streamr-client","version":"6.0.0-alpha.16","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.16","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e488e5a4d21b908c1733231c7775ff005c27636e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.16.tgz","fileCount":231,"integrity":"sha512-Lzj3/IUynJXUyfiS0Nc6NLLq61gNJqgaqg/ueA0yr74Ci8sk1jfbis5GwDUf888vDfa2IirxcZhsPLMjJZ2V9Q==","signatures":[{"sig":"MEUCIQCLbVmkGnCZUkobWhnppRV9wvbETl2NRUjMuM+W9r1KZwIgKIVN5jGtSDf6g1tL4JuIeEA5vaq27VQaQsm4gJTi0AY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19931947},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^3.0.2","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.16_1634667947874_0.9310166515111133","host":"s3://npm-registry-packages"}},"6.0.0-alpha.17":{"name":"streamr-client","version":"6.0.0-alpha.17","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.17","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"6c1a1031cd2d141543302b06bf6663b5455d3104","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.17.tgz","fileCount":231,"integrity":"sha512-wdjY1yZtJgh087SY3m1RoSDJE/qqiB9FfBbfvrK7IDpZBUXZJzSHyLfBdiYKOTxCcAWocWa5oksyoAbJiuKGSg==","signatures":[{"sig":"MEYCIQDXxpeA57r6jNPXc5i87n671nKV+BtErzC1/GWOho2SowIhAK7kxKDFKDhvqJggJ53VfVLN8otVCmi7ubw7/TxqHjts","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19932591},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n### Breaking changes notice\n\n* Support for unsigned data will be dropped in the second half of 2021 or in 2022. This means that every data point will require a signature using the publisher's private key.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"6.14.15","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"14.17.5","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^3.0.2","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.17_1634670044875_0.8296805318577556","host":"s3://npm-registry-packages"}},"6.1.0-decentralised-registries-experimental.0":{"name":"streamr-client","version":"6.1.0-decentralised-registries-experimental.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-decentralised-registries-experimental.0","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ace64b633a7aa6903457b8bdbdb074ee4fbd0e02","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-decentralised-registries-experimental.0.tgz","fileCount":425,"integrity":"sha512-eTjfmfRVG7t9Hw6KAIBs/DSutwC3cdttaen+sKU4VGh41m427sA51sxz4lATxJO7urLtHilFMcUXYDzLngadVw==","signatures":[{"sig":"MEUCIGtDRAJLZW7KNchx979o9fBXFcKGWCISYD9i8tvh/x39AiEAiO+X8jPMiWV6D/JEg4Ib5nTuua6Ick8DWjPrpKUZ4o4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7658592},"main":"./dist/src/index-commonjs.js","types":"./dist/types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./dist/streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./dist/streamr-client.web.js","default":{"import":"./dist/src/index-esm.mjs","require":"./dist/src/index-commonjs.js"}},"private":false,"scripts":{"t":"jest --verbose --forceExit test/integration/Basics.test.ts","docs":"typedoc --options typedoc.js","test":"jest --detectOpenHandles","build":"npm run bootstrap-dist && npm run build-node && npm run build:types","clean":"rm -rf dist; rm -rf vendor","watch":"webpack --progress --watch --mode=development","eslint":"eslint --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'","vendor":"SRCDIR=`node -p \"path.dirname(require.resolve('quick-lru'))\"` bash -c 'mkdir -p vendor/quick-lru; cp -n $SRCDIR/index.d.ts vendor/quick-lru; cp -n $SRCDIR/index.js vendor/quick-lru'; true","fix-esm":"mkdir -p dist/src/; cp -Rf src/index-esm.mjs dist/src/index-esm.mjs","prepare":"npm run build","coverage":"jest --coverage","benchmark":"npm run benchmarks","test-unit":"jest test/unit --verbose --useStderr --detectOpenHandles","benchmarks":"npm run benchmark-publish && npm run benchmark-subscribe","build-node":"npm run bootstrap-dist && tsc --incremental --project ./tsconfig.node.json","test-types":"(cd test/exports && npm run link) && tsc --noEmit --incremental --project ./tsconfig.test.json","watch-node":"npm run bootstrap-dist && tsc --incremental --watch --project ./tsconfig.node.json","build:types":"tsc --incremental --emitDeclarationOnly --stripInternal --project ./tsconfig.node.json","clear-cache":"rm -rf node_modules/.cache; rm -rf .cache; rm -rf dist; rm -rf vendor; jest --clearCache;","test-flakey":"jest --verbose --useStderr --forceExit test/flakey/*","test-memory":"node --gc-global --predictable-gc-schedule node_modules/.bin/jest test/memory","copy-package":"mkdir -p dist/; node copy-package.js; cp -f package-lock.json dist; cp -f README.md dist; cp -f LICENSE dist; cp -f readme-header-img.png dist; mkdir -p dist/src/encryption/migrations; cp -f ./src/encryption/migrations/* dist/src/encryption/migrations; true","test-browser":"npm run setup-browser; node node_modules/nightwatch/bin/nightwatch ./test/browser/browser.js && pkill -f server.js","test-exports":"cd test/exports && npm run link && npm test","build-browser":"npm run bootstrap-dist && NODE_ENV=development webpack --mode=development --progress","build-example":"cd examples/webpack && npm run build-with-parent","setup-browser":"node ./test/browser/server.js &","watch-browser":"npm run bootstrap-dist && webpack --progress --watch","bootstrap-dist":"npm run vendor && npm run copy-package && npm run fix-esm","postbuild-node":"npm run copy-package","benchmark-build":"npm run build-benchmark","build-benchmark":"npm run benchmarks","install-example":"cd examples/webpack && npm ci","build-production":"npm run clean; npm run bootstrap-dist && NODE_ENV=production npm run build-node && npm run build:types","presetup-browser":"npm run teardown-browser","teardown-browser":"pkill -f server.js || true","test-integration":"jest --verbose --useStderr --forceExit test/integration/","benchmark-publish":"node test/benchmarks/publish.js","prebuild-benchmark":"npm run build -- --config-name=node-lib","benchmark-subscribe":"node test/benchmarks/subscribe.js","test-browser-resend":"npm run setup-browser; node node_modules/nightwatch/bin/nightwatch ./test/browser/resend.js","test-browser-realtime":"npm run setup-browser; node node_modules/nightwatch/bin/nightwatch ./test/browser/realtime.js","posttest-browser-resend":"npm run teardown-browser","test-integration-resend":"jest --verbose --useStderr --forceExit --testTimeout=40000 --testNamePattern='(resend|Resend|resent|Resent)' test/integration/*.test.*","build-browser-production":"npm run bootstrap-dist && NODE_ENV=production webpack --mode=production --progress","posttest-browser-realtime":"npm run teardown-browser","test-integration-no-resend":"jest --verbose --useStderr --forceExit --testTimeout=30000 --testPathIgnorePatterns='resend|Resend' --testNamePattern='^((?!(resend|Resend|resent|Resent|gap|Gap)).)*$' test/integration/*.test.*","test-integration-dataunions":"jest --verbose --useStderr --forceExit --testTimeout=15000 --runInBand test/integration/dataunion"},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.31.2","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.31.2","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-decentralised-registries-experimental.0_1636023330666_0.23574941444386077","host":"s3://npm-registry-packages"}},"6.1.0-decentralised-registries-experimental.1":{"name":"streamr-client","version":"6.1.0-decentralised-registries-experimental.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-decentralised-registries-experimental.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"41c2c6db4762b9dbfbe3d7e6d54ef5b91ba49c61","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-decentralised-registries-experimental.1.tgz","fileCount":235,"integrity":"sha512-XUkrFmArhAsRFeVzU+glj4iLZ4FTRK/pHZPMCNHRZMyMSQfnidpC3Bm8Vi8cqy+ZNA2P3VViKoQERP4LtdsazQ==","signatures":[{"sig":"MEQCIDzlc65ATXJSSxjOLLKQJlV0B375STPM6O5UB2D+9U2iAiB5W9aLmA1ntJhXst8UiQmF/QJtsNHIrBC92fEfEkKucg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29526645,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhk4dKCRA9TVsSAnZWagAA+iYQAIA651do+smpxmXhmyel\nLf51OzmEnpwbhwfrvJSOn6J6zif94EUK7KYwnlM8J9xgym+nPcFExRB8ONch\nFe+Abf5VgLm85aYf92e91kKBm2uvjuB0gHuTyQfTqcGuy6y0gsjP6Hq0Us+x\nn3IPqNcik0XBh9xWNlIT0LT/9IB6A1S6v4FeJ91xHBkkRecz2gF3XhMTHHCq\n+cxA1ehKH6uSfB0QTiOtOEEqgP1IJJUQiRBYUNAyaW4VFeSFobR98Zdy6m5e\nGwGieEdWwUWe4HSRNM4GjsAzSySzcYi7EPZ1gvSb29ogTOuxzhJaTiI15G+1\nH33E0rOMovNML0cqaM5iiSRqc8ST13mSLd0f2cW346N9q+AjnUiNDd6HRhT5\n7DAmBWaLCtvPPl4vuvf3NvfwM4FyixY8iQDM6nndlJeyEFJWGAtZ0lf7Po3x\nOV0dYBXU+Qb4VH638yY0SrN6kj38e9GIijpkX2QALsRtOkBXqg0Q9h8d1Yy7\nYVA73lkuoGdWZ8J0erA2Q+sebE5s1XlS9jCB0plMhEiVNVuAGlZ7v1hZ1tYe\nk0Z9eXDRFKHkCaFYC/p3M959jHNvaNVXLFGvUXshGb9QnvOjmi77t/AOZu4S\nbhPe4bUFPP4vcSVE4FY7VLzSAf3edvwigJX1E5CSb/dqsoguWDuDazCy4pO2\nmrcY\r\n=VtLF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.15.0","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.6","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.3.1","@ethersproject/web":"^5.3.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.3.0","@ethersproject/wallet":"^5.3.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.7","@ethersproject/address":"^5.3.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.0","@ethersproject/bignumber":"^5.3.0","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.3.0","@ethersproject/keccak256":"^5.3.0","@ethersproject/providers":"^5.3.1","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.3.0","@ethersproject/abstract-signer":"^5.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","util":"^0.12.4","sinon":"^11.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.3.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.21.0","webpack":"^5.40.0","benchmark":"^2.1.4","ts-loader":"^9.2.3","weak-napi":"^2.0.2","@babel/cli":"^7.14.5","nightwatch":"^1.7.6","typescript":"^4.3.4","@babel/core":"^7.14.6","@types/jest":"^27.0.1","@types/node":"^16.7.6","@types/uuid":"^8.3.0","jest-circus":"^27.0.5","webpack-cli":"^4.7.2","@types/debug":"^4.1.5","@types/sinon":"^10.0.2","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.14.7","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.4","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.3","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.14.5","@typescript-eslint/parser":"^4.31.2","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.31.2","@babel/plugin-proposal-decorators":"^7.14.5","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-decentralised-registries-experimental.1_1637058378497_0.7648962076564556","host":"s3://npm-registry-packages"}},"6.1.0-decentralised-registries-experimental.2":{"name":"streamr-client","version":"6.1.0-decentralised-registries-experimental.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-decentralised-registries-experimental.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"87766aee4b23662f4deaae37a0610e1949a22e14","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-decentralised-registries-experimental.2.tgz","fileCount":234,"integrity":"sha512-xGLTSet4ZSwlnWW/QYFAoxaKI0w0y7H2RxeU//DNloFhOt6Cd9DEuOVlCg+nRO4785i/aCFKXgOU5xWHQO059Q==","signatures":[{"sig":"MEYCIQCkbIF0ypa/R3W94wh6UASzp/syg88hOqpj1IDMXlJyFgIhAKl44H3A+/H2XjR+aDsVIRahVQpAuTr7zwiMsxYryNZt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14814206,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlLI9CRA9TVsSAnZWagAA5kkQAIESwcZhT/gCe9YOTvhk\nvQ3+pVcvxAcdmZkoGR6Qw5aoZJPZb9e3v7fmx6bDfbL8biOKwWUCI+y/zHVJ\nctzi/DKysjgC+sibzCaoFNDtNI4Qi3NS87+JktqszZ13+APE+gWJ+fKxw+A9\nnVGICDwLSmS6anGnvBkRYlp11rqRlhx6NkyWFqGStKL0ylJQfZdg1Dq6yg5g\nNhOJJB5yei3eZYoHCemOMfrYIcSRoVDizwN7BE6BAeERcGIJ1yYd/K7JUyU7\nqOplTNNVO+JeHPrrbCcAfnkMO46cdCwvWqkyFjBvmvL+3oxxC3tS3sgFtbIU\nATX3AkUMkMEv0Nlq8Vyr6WGujvlmGZB6Paf5bHJlqBkDjzcM/+wzGBbEyNqV\nxTcFMKliSz9gaDZbQp87wyoHdGygAd2OeQlaEYb5djARM+JnHRurbNUcKrwt\nCrC+VH0W0MS3zMxgGEng1j961l2VjEbQABN7ck9bnNNJ3dPgAowRdWFqo7R6\njjDXkNFUA3FFI3ayA3eoCa+jUPk0Ua/ndXX7m4n9l0AvfkI/Iz1FQpGsGg9f\n3d+hZ2lE9IHO7f7HEdCX+tdTOfREJV4Yd0vrOYZgOBWHCwJtoVobKvz6hZk5\nyFsgkR1+E9Kd3bABvizEE6IM8Qt1wlELcUdeIghdMUm/wEAzASOEgGl5rOD5\nYzbW\r\n=kjNy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-decentralised-registries-experimental.2_1637134909740_0.8143426308217407","host":"s3://npm-registry-packages"}},"6.1.0-decentralised-registries-experimental.3":{"name":"streamr-client","version":"6.1.0-decentralised-registries-experimental.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-decentralised-registries-experimental.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2f1d624e9665ec71fc86d9cfca07755912afa8ff","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-decentralised-registries-experimental.3.tgz","fileCount":234,"integrity":"sha512-TRd7Y9qFqkRAnPdnc+K/bX4qx+8X6AFIH96NwDN48AshAsScjWn23mJv+p8+u/UEGoZNDWpxvYHY1khJjFTpnw==","signatures":[{"sig":"MEYCIQDmH0gS1eCFqsQ/rFLuzt3mcEOcR9H4Lli39NrZLi16TQIhAO4vn556lPNCJxZtBajN/tyy2fHue3eUG0Cde/UIK3xD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14747092,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlO9tCRA9TVsSAnZWagAAuEkP/0gNPMpxisZ+r3pJogl7\n9VdrgmNtVTGHyCJK7xDrKJOn7OaCKQC7ChFQSxLa2LuvqXHDekvQzfHhkWPi\nOGY3DbhSn3lJA0dDWw3xJ+XfSDb8T+qKQgY2eZBBVptgDWZIUzeIAXtvy6qr\nwOfzTDu3KQwIbITEudWDijqTqLoSUPmmCxQF20jiaxro8QY/6xqQxrqat6rU\njWTPunxsuGziQmSsIfBc5kcn2S73u6TuX2RSKMq6PXpinrTvo3f0l+AjIWjm\nrTFesSI1BRlF8lj0JZwA3i3Af8TigeLY+AXG5XMdQ3oEHQ5MCRJuDJjgrY4J\nfpkBMBXm03ppqYJrcoQwacIVTDBBNXABwKvP6DEzlJwnO/h+5oMoVN9cf53Y\nnnnMFYmptBau63FdmdMH7LKfXMP8eDa68qQeyLK1sjjqF7q0LMcMNrKMFB+J\nI21quub28Ce1D2tvNJVN0Of4jAVFzGQXMCtHUKYY2+q+wDNMdtj/sHm5cU4+\nXJqyPjFYZwyxwUAyHGBupHkRnQY1FxJU613UvVIYNZ63hrDO5gMkcwrLPRSt\n2MCMgXyE6XD2hui8xydJpqAxRnzyPCsv6fiRquqRT0Ee5JcmcVxueLMhc9Rk\nFpjYCQnHcIOPR7+YodYTWMc93sY6zDSAeUUK5hiO2nXLIxwj+5pwY+uKV6VE\n51xG\r\n=vQjc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.18.3","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.6","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.15.4","utf-8-validate":"^5.0.5","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.4.1","@ethersproject/web":"^5.4.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.4.0","@ethersproject/wallet":"^5.4.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.15.4","@ethersproject/address":"^5.4.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.4.2","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.1","@ethersproject/keccak256":"^5.4.0","@ethersproject/providers":"^5.4.5","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.4.0","@ethersproject/abstract-signer":"^5.4.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","sinon":"^11.1.2","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.58.2","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","@babel/cli":"^7.15.7","nightwatch":"^1.7.11","typescript":"^4.4.4","@babel/core":"^7.15.8","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.0","@types/sinon":"^10.0.4","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.15.8","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.2.5","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.4","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.15.0","@typescript-eslint/parser":"^5.0.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-classes":"^7.15.4","@babel/plugin-transform-runtime":"^7.15.8","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.15.8","@babel/plugin-proposal-class-properties":"^7.14.5","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.15.4","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-decentralised-registries-experimental.3_1637150573326_0.9856065326597847","host":"s3://npm-registry-packages"}},"5.5.0":{"name":"streamr-client","version":"5.5.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.0","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"73ce11b3352aab6cf3a61955089d541b7a612118","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.0.tgz","fileCount":184,"integrity":"sha512-DlauGhjWWf/jSJ2XE5w2F3ezS5GpGEVjidvE48sepFw4WTTPtj/4ZmaTB5rEKoGsGr7wkGkBeQGcz6LVzZRKOw==","signatures":[{"sig":"MEYCIQCx7H3+ZcKDdOxGGZh7M6cyLwZYqPyFtWqX6IBAW0yCigIhAOjoJn81w0gijlDDJFs+Gb/uODQzkXooGy4p9+wATZv1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13871077,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlP9fCRA9TVsSAnZWagAAjV0P/1t8EL1VNtjIhD8i6vER\nrhD+aXNRBeL/mE/jn34s/eK+xuQtE/5Nvx5RVHWyPowZEojoZ/AB7hmTW2VT\nF3ScVrvAF3xRia2H+F0vE83l79qf9L2cbvPf90AKsS6ojTqNRQHsRq0YXoIj\nYRh+jhnJT+i3banR2ej6J+ES6vZ1L8KRCQpAlgFPLY8CYxzfD/D9KkK/2KD0\n3dptBYqsWj9SQZZskCPJXLUSW3kGbOxIIyUUjLYwQJyWXb/7y9o160KBPYi1\nrkW2twHDC+Dzm9jPlBYRnI7oNBQGW/qCUqHbo/Mt/Hr8RBKPFwDND3DgPPSx\ndYL077DOWQvkVInjZrsjUboXF7Xkh47VUhc8Ny/h9dwuO0CQjw6dqA5KXKB7\nO+JZ/m41dGxGXJaXicUvCCSAMX3LUXHBIBGB5PZHg3FbDfQOSq8kELvbH9fV\nTMhc8otJUtt5YsWVnQ/1qNIUXQ2SxhV+vzqOk2MfYxJwtPo1+VzI0rZJej4m\n+CD1tanJ7xearx8QqfQXgzzDkG++LbP8klPcrI3On9wbSLyguR/rcnAPYCh8\nJPWXlYHSxpolvT4K2/2VRjhivahIuaalQH18BdAqitE+lAmPf/kzUL5gNs3H\nvvbVUb98qA+fxIgjxVn2qSfXH0d2CZPuwd1rYpfShREO5Wxl7ZFzP5eqi9ek\ndBhq\r\n=QzCo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.11.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.1.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.0_1637154655346_0.3171878919081288","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.4":{"name":"streamr-client","version":"6.1.0-ocr-experimental.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"bb35495997117ea80567ebc66cf05dc397bb8eb9","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.4.tgz","fileCount":239,"integrity":"sha512-3erlX8Dv4Ftgmal1yHDWYF1xp4AvtaQFWNUMyNex4wrNfUawGKF5v5+04E52i4+fWteRaGVNYs8vMQHE3S1zsw==","signatures":[{"sig":"MEUCIQCHZdLP81QJL0MPgsk2XgJwNCamtbr/31svYkse/DEpQAIgZKpu3+kT3Dxj9URTY0unqs/ioFOAR27CRcLUgEJbbtQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14759663,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhl5quCRA9TVsSAnZWagAAZ54P/jhXYX+o6hAsD0Gbh4sp\nRsMa6VcziS5vB7e3llQzW2JxBiy7TZ/sZYZeqjVUNx9ChbDu5zpXJcvBHZ5z\n36V7Wgi5IquphYwMLm/6rQQRvvMwD5bQI5Lu1nnvxt07KzxoEFftnPm1ttm5\nusDe4UHYCZ89XwZ9xefDfkGXmZx7AlF5+wplkIbYbVx0Yc8KCYaqK0WbOqGx\nbOIw9op/fAHYc6E3xloYhea8gH9ib8pls+cVqmsHzUkXl1ocCdaplBSCmYCe\npc+3vT7LWvaadDifCecrk0iRgvKz8xvIc0knuOMuNWQFJwWkofiZl+8VVTr7\nZftQGFBdpoPtShcLQcjiZuG19EQNPuSYObE38qAv/8z5ruK/az5YKyZ2vBnL\n4GZwEbcUV/GhDIkqgZaDHZBwDF2PtdEPEUuLk4gYGjVz5UUWRZXAJq9jeZYG\nPjQSmXQrskU4O+75iDAGczg9DeTlFX/SQfy4pOKtQbF7EQVfx3ImDfWZxmNm\nNzhtb6CchSicxyfs7SZF3FDkd+Idy3N0Kg4+UZ6nlWE0hqW3j7DSBSTeQKe5\nQwRgFptFnZdx6+gusm5TXRZxc15+v92VrexrP4WyhzcbEzWI0JtaGLvWXn5E\njo7Q5G+PT6rg8I847POcG2MDMH/rieYoUHr1saZaq9zJAKTKdqlXIkReIsiI\nLJgf\r\n=G8JJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.4.4","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.4_1637325485884_0.5730894075219541","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.5":{"name":"streamr-client","version":"6.1.0-ocr-experimental.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2fa9fb69028f18893750af95410237ab9e1eb9a9","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.5.tgz","fileCount":239,"integrity":"sha512-IndZP+ecvwPwi1oKbzE2FRf6aVh6FIIBD/G1P8JUsEI4RFQapNXULDm3QVe3gNeuh7k0nPkbQ0RAqzXN8IyJ8Q==","signatures":[{"sig":"MEUCIQD8TaYLuz6jhkQ9xMMb1mpHSmzFz5ziGR47u2sw25diPgIgYhhi+Gqhf9us/BG985EFS3rzBN/MiqeB3rUeyclkZcI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14845029,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhm1SfCRA9TVsSAnZWagAA3qEP/iGuI1ZOfHHH6feJJvmM\ng9Ovf5/s59tzvhIDHqJfJoq56bP3IPQ/o/tIlsIk5EfhfMSwGpU/YwLdTBGW\n8wQYRBIvPU6pYgRW9qayPwKX/3r9iR3v0Get08V5T0bH4L6EsNrIKrF0Bbv5\nmpYE9ewrNbP5zMujOEUQ5Ho7EMW7GLadkwQj0eL9OXVJtqKfuR1vI+S4ens0\n5qKFQYcPRhtW3Dlx/W9JT5t8z+akWb2FTneBBc9ijoA8EXH3VVz/VDjYl/WT\n8tGrierNdoNM+hWrUw7Jtem5/DX7CXxYXrz/XV6i2dZilMPsajMjyhcyQne9\nEaojHLRyJUEYrhUlTjryXD4rcKYYvG0YWBp11gtY/HESj4jYdg7IvhlJEF/+\nNlXUNCGbvyrt25JFtdZ+DTQceE5T3SoMJ/hNxDBlYuqpgGykO5es4sa7aS9y\n60dTcX+62HMMvVNCeJgcvbr9agIcXP9PU00G9bzXnaLHSsJ2N/tLs9VmJcuH\nmwT2kec5q6rg0LynRyRLQ8nGIpwYcV80XXGAvgLRo77KwMfkf0rTXtwV/nyN\nCFfyK9wxPrYM9JibgCAV5nzzrgPcCsq6aYrcRP45KBJKUQwhPk/VL1upvNIn\n1TXUWfq635D4PhMenF4+mrxJYns/Ksk1oPqv0g2rtKgsN0YBvokIf6imOCQE\nxeuK\r\n=8qxD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.4.4","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.5_1637569695688_0.8435512556944793","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.7":{"name":"streamr-client","version":"6.1.0-ocr-experimental.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.7","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ab4f7f071e9eb0bef2a89b4fa22ee5bb66ddc8fd","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.7.tgz","fileCount":236,"integrity":"sha512-NLvXIY2DhqRztF7haTSOgjN3u6GmcdUeCwIJZt7MtPKuDs2/dCV6zXe4ghbogDUsk0tnU5TmXRFofkAN2LOBNQ==","signatures":[{"sig":"MEYCIQCqgbHE44sXZo31QPAO/uerhAGgNQ8N/m5GzROwnZV9kgIhAOx7v1SX8VmjMFNS7gM1YfLHKK3VepBZwKql41gz9OkJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14837139,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhm1wdCRA9TVsSAnZWagAAfdEP/Raois07egXYU+mX1xBU\nJaSlj+om8KtYdgfqpEV3BOFJmkdcYC5o7gEiMtB/Ng2Eb1YZJe2MNbpN7UdZ\nnmMgz6IPX5mhDTULicPAD/fWgWZ+1TgyeJXtO1AVGMPYAXmwIa4B9a++6m92\nFPfLyTzep6N0PBrVabw3rWdHe2weBnLP4ZW15Jo07nB/vYg1bICjx8yKZGof\n9n1TDYioXQ6OsE49UgIokPVentQltZCI1HvxI6kEYjFbfHWx5mNH4QYACnvT\n9n92KYk5PJz4mQXuIGtINphd0+q48mJggVmCm1ETfj0fLLVNMLBGNdiQ92Xs\nI8VWaPugPCNvu1RGj4EVXqyoItk9kUhUby9+eENhrKvUjYFdYNdzRdfQHWLz\nZ40Bj0ZHX3ZkT/1kSCLNwkKllYLb9EzOfSzhxPBXzxHbc0Nmmo5H5FXel6bY\nxX0UG3yo3OjegJSZ9Cgz+Hscr+e0OdV6P0VvbnAycCZkMxsK/R6naUEd8ZBS\nUPt2XAcz8lR1L79ajwsbhoAS6IKYabM+cBFSBm/LP0JIBEgpAkdr/P+walCs\nUmKVGK0RmTFSchX/YfKId9ZqOi+Nlp4p8yx1/ui81qcU7W49KiCj/w4uo2nV\nXCuyVPntWWrHtqRHiHV0rGQf3E9Ih971vxKRaLNDEVRUQkf/NdrwsxMVs0ns\nji3V\r\n=9q7s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.4.4","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.7_1637571613473_0.41035895892616225","host":"s3://npm-registry-packages"}},"5.5.1":{"name":"streamr-client","version":"5.5.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ed4b9d3013287eac86a9d00d57df4d906286f0fe","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.1.tgz","fileCount":181,"integrity":"sha512-4dU+slV8XN1u+HyFPQI9ll8WIrsKvFPV9qoX4NXL0NZ3jrEK3CluwnX4hXkTiuuontmsngf+rrPTKXKDJhGURA==","signatures":[{"sig":"MEYCIQCOQndx0GenoUQauzj49NeSl4yPQhYccdg8Ky969U0MNAIhAIQURYkGuvNtx0SlT9XLbUIXln7h3noTKR4ue50eDgzH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8934126,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnO2/CRA9TVsSAnZWagAA+GkP/3naRB8jiA19QcOr1WS4\n4eCf1XuRTcmhHtURbxspg9Qd/muFBfjA2AraC7jgro7fk1yQqUIcw7kvs8Th\nlHxUL/T+eKp6/04a4N6ptxcE2tOTcKIJQC9uMK2lH4MOU7PpZlVi2AdVirQw\nFHyDD/qWUMmx4Sijt66qmUVa9LFUK2kDb9xp/Uo28vJ2CD84oyF+sDZc1FyB\nBIQqbpnDDCmllfUghCZGVSZWf/XDUBW+MZev0OCh0cRd7I9fiYBMPLJx2R0d\nitIWaRfQfq1YkMCvJ0ObOO0n+GI/QE8h5RePOrftFcf6dnQpL/ZUCSMoE133\ndqBGWmKWQ6ev/awO0EQ4oK9InILi7ugA/E4aExs4WwXgKPJy6wz5PnnPMd7X\n+a4tyRwpR+mxR30TDiqY2kPK3okT6KCrRn+Yz1I5slkbemidF/JC4XIWo0Rn\n058v5FRtIYG06G3Wc8DrjPkCQKs5klUk1F050jHMAw9rBaOUeU9/RbqACY9m\nteqhU3zP3Njk6Y8/dBQzdLadpGd/1HYl3U1tcTKf/WfOlY5ZoaNIRzLX6UDk\nDeSClPaaiASNQKlxJJmtCYPXb8sBVkh0qMq4T5sus8ZD4gM0vaHg3C6rdbnO\nZ8w4QEQq8BuuiABaO4x9JEkfqtuarriHhYMmVOM6xyLK8YTAqLE4gxkrQ518\nHNgx\r\n=mNCJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.11.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.1.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.1_1637674431629_0.731977427444777","host":"s3://npm-registry-packages"}},"5.5.2":{"name":"streamr-client","version":"5.5.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"09dd0d223ee818c3cf9e86aba64c08cf4d30ac74","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.2.tgz","fileCount":181,"integrity":"sha512-DIz6sgJ6MzIwM7OVF+uOOEntuPwoiGfHjgVA5te9tDIWVEkUgkjwzfTCM/tIulaHQLWRbLFcvlvD8bPnF7ZbSw==","signatures":[{"sig":"MEQCICWCCgVbzv1NDHHRfOSsxQOieAuf25oRlP/2hEzI6acWAiBRcJSnW0eWPsfwlPfJxgy3uR5Lqz50dLWZZT5rKtHsew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8925958,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnWWDCRA9TVsSAnZWagAATFMQAIywA1M8aoakvc4cVgQ7\n50xFdnkoGX3J2qxQVeXj5a9jUIMlAWLXQkBCH7P/XXIba7L+0p8urJENOm7f\nxt4tYV5Cl37ugrhTESpRVfqGLwo2GmOqiv/O6omZZAPH4dI6Nsu60UK7CGWX\nrmVKmEOGlYnGvu+y1szNCN2+1nwgDtt2gnn5zJ4FRv7EMfB6JxamCzUNvwYI\ntZSmXTANzHXdTCBezzi14M9OrxDdcIXmHYKaWWRwv4Yyc428/fIEm2fz44Bx\ndzhP/9bsK3YJVHoBWdR93bZ1a2xkQ3izWINADYyjI2nhm6DT/Obeywia9llu\n7vXnQ7l149CZA/wCILcJFsVKFD8f1YJzxqYbXl/QsAqKsRM6QUqfJQeOAbkX\nFPaVVnKcRt3PVvhhbcY5+xVhS7JiOIpD+OaVT+vDE7oITLsCDKeM4+9Dt5mJ\nnO0KZdjjB4fi3DwdLk15cVHqF8BjT38Y/sm3r1BabbOTzaG86SSSCLtamTaQ\nwXW1uM/DVEG6Jz7Fo29QgIVr3Dw2OPjD3KMhP8pYJm+UNU9Bghulpc/g+P1G\n3w61CFNGU8zgz2iZ8FQGhq+5tFjCV+MRE9jobbsbNR+qMIX8MxxHopw23t7E\nZPoItWPQ7RMckdGnfPfvIiTmCHliSd5cVTP0F3WLb4h3sH8f9CJXwo79ZudX\nkXch\r\n=8KJG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.11.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.1.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.2_1637705091699_0.16870703371172802","host":"s3://npm-registry-packages"}},"5.5.3":{"name":"streamr-client","version":"5.5.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2033fdb68ccca20f7c79c82484d51d1ad222a0cb","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.3.tgz","fileCount":181,"integrity":"sha512-8KDh2jl8Dbl9ut21uVtugf7ecWFKUShS8wQ149jV1MkgfXADsTZzxbkv5XmQ/OVIrAVCn3iQ+JXDmTXLQJrZcg==","signatures":[{"sig":"MEYCIQD25w6mtc1zL+QTBJ9h9lxqaod+/62+LvS1tIqQHMi/aQIhAJjuUL5FyRZpGzw8xNdJJC9TzgPAzc5hxzf8Ybvtr8Gv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9013960,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhn5Q7CRA9TVsSAnZWagAAw0kP+wcGiudCeqpHmeYJU3R1\nSXQDzgOA172wLsqkNnIN2bPx8OYM01aGb3qIER1qJt4Zo/aonZS8/y4Jruuh\n3C6VxEORAdVghV0+fSwVQgdsDwza3e1b9lP2wqt3ngI6IqVxQGrrV+CPib4U\nX73dhIHoEpx4Cgx55nJaTSVjUcu8xUp1sGZ/V5YsfNqCPKutiZaNy8rYXFZf\nlSoASNIPeMxn0mpGzEVkFE34U+LveDqFEbVzAPCYXvGy+/ZtEVDKg5mR9Jgy\nrGsDjwQuCvlYZOXdhDzzqB+U/xoQIIq3zEaiILr7IKCqyFamns/9jObzBzEF\nLLfaN+ix2AtzvG7Ia8o1ubm1YFSJqDLh0DkcpLQ8clRPx8m1CeBaanxiI6DQ\nFlJCJA5TmHtBZJdnm4LWp0y52i5ef6ENEoSOE+EiyE75CK6Thd54q5hvp9/T\nkWFrgoM2Kd/4sRnMltZ82YhN5q/IeCuq+X8T0DuwaeLG2evCobpyEQbV3xbO\nvJEibFseEFp8C9O8jXgsER9blxll11CcMSwO+rpr0fua6Ka9fNHOwvp5KpgJ\n7qlptO4OB5nlF6ICpZttM2PDk4p0zGC0em5jvs02Xf/zXZ10XflQkzFXBeN6\nDhipo292YQCSHoI/35ixL9AWR+kl5vaNPhVUUb5H0sOLb1ZVjKrJdkAwV4qd\nZ7+t\r\n=Zvso\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"163bc6ba5622aae6a18b40a503e3c277cf72827e","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.3_1637848123074_0.9927388020593502","host":"s3://npm-registry-packages"}},"5.5.4":{"name":"streamr-client","version":"5.5.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9e91727df595e4f3beb273b3a48ea2e12cf1adff","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.4.tgz","fileCount":181,"integrity":"sha512-lG2n/LUbENCjLNjsczcDepx6qrSIF/F+Y4pbV9vw8b4likHxJFf3KkTuEHxVmIFViqF4EdxSr9Rqi13RNHe0/Q==","signatures":[{"sig":"MEQCIF5kzTuc/qIQh2zDMtH+eZOXWkeUZrtDkyfY6Hg3WZy/AiBoi7YIN3i33i/uiogkPHr0/trYSdYdZ2mlY6zHKd5zdA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9020004,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhn7PPCRA9TVsSAnZWagAADX4QAJxWLedL2od1Tlip9P0c\noLxBbBw66csF9YFVGyOIWJpVRyLkYC3E//QWYhYtKbFD1z+fqa7fK+MpF4vb\ncdvYGbnmjJuEP5hnUPDAP9/UEGGyiD3Ehxcu04t8l7paAf2Nccg4uMOh6Fka\nCJUjRGpydswctOhgjqRdnrRk1sKafjGYu9e2BB4PSFHaxvdjfQCyrjB8lkMN\nfzfeiEpfORXz2AXqij6gper1DrGQcVttzbOPhkBhwQC9UF30+SWBKZJKmmxd\nh6RHWkyzwyZ7zylZ3GTBy5DNzCB13Mug5e63SuWlui7eIfV14YfSJRGXIFVL\n/Gbuvpw4pci37sxOWoXtKlFwYZtefGAtgq2xIy4GI0jul2nppZERw4LXOEIh\ntCKovFbNfSWcLF3pBqxLBV0nIwh4Q+lCd9pZub0emmzev610ndKvWosPqOCF\nKi8Qu4b3tkxUdaJlUn6Yer7iYhVP287NBj98ZcZWvhFigO/xpMuQ3O4/yQv6\nRKNXt6gLXuCgf4cirZdMG77sImA3CtvenBg3c1tqhd89NTpQzeomfQfrb2j0\nHN+AVvE/+1kceYfZYJrFTE+qwFwni+RAkJ4P8r8i247VuXjRvOtQIfpkHZad\nGmYKow7HU27JKXIGwmGML80+U5NXk8XL1sZ6ImqMs734vLl5LeQ+udquHIb+\nZ/KE\r\n=nKn1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"163bc6ba5622aae6a18b40a503e3c277cf72827e","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^92.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.4_1637856207750_0.4352406622828271","host":"s3://npm-registry-packages"}},"5.5.5":{"name":"streamr-client","version":"5.5.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ed6e57ca9a53656e5ab716877f630c83f4f92e98","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.5.tgz","fileCount":181,"integrity":"sha512-PteeEfpR4BdGLY6tXXnX9VOwqJ3FnQ/Jek8CngvVUEVqDHGgHIitIC31IA+2ODUgIbb02zT8fSMmHjUB0+Yj6g==","signatures":[{"sig":"MEUCIQClpZuVrfFjEdMWUXu2a3M/mDESwinWKnYRXDovDTkZyQIgNmEaf85MHn8lJkYY1ae6AphnRSFXWq3nRX/f3EJsA0U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9022730,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhoTnaCRA9TVsSAnZWagAAtb4P/0FoaF9WdEduUq0vSRh5\ntrDrS7m1s9tg6uiSzGI5kq1iX8Vij6tCk+ntvdGiRnsktTtIe13HlgYbbx6M\nszixcK4iWQIdo8Ry09USDEd8Qg0CDQ4Jdj5WpuwLlPf/97q0SfqNNKkcOdJr\nL/HSiDsmD37yCFDS+S0LpDII9k0UcmYTKZVf1+f26D0+tolPvv9vgeYYpK4m\nACBye+Re80BzIbQaCGQJYqcg5mfLwb0CJqnF6DV1sedmyYF/GFVnRk0BCBm/\nhVbWK9qr8+4yIgUGs68Nc1Sl5HIJGLjEsDMDv38POwFR476KJGirak6dxNdz\ncJiie0y+xahNjg7wOE1eT+gqvcatSePmuyxRcCjeZDrHQMHjfz3mJ0kK8+HH\na9YA8xeEb3TzsqTEopZdgddiHdqBOpNwjghU2WCO4N/NSGFrjqoKLSxyxUpv\nGYdpAOLsy5vH8cIU6d0lXfWAD+BMc0rlDIFdsZ7lXB5dClZuDdHygePb7twU\npLB4JZL6d/WIFzqpklBeFuxPxU5eg1sDtGw6xICDAK0bwFDDgCqGdtSeUf01\nNirHbSqhg7S19MAAYE+tEK1AdsfjUARxFkb5NG7SRB7RBDCm2Ucm9t654xib\nw6dsgqXS3Pzx4LdWa/YXDhOmcNlNrTNf9uInV5aYyX8Di4eB2/+5gpZNUsoT\ncL7l\r\n=Gjla\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"a55105091597857a56977e39b31f2cebd746368d","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.5_1637956057879_0.5042576931774105","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.8":{"name":"streamr-client","version":"6.1.0-ocr-experimental.8","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.8","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"d1717dc520087658483e8b7eb3a4cedd80b87fd0","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.8.tgz","fileCount":236,"integrity":"sha512-dTNqo5jZzUWWvgVTy4sMg35+AatAiJxcRxYt2rYlqd3Ozvwfc9hlhMTEgEu+QcY6eXjbP8pWZqa9+iRyQPdDpw==","signatures":[{"sig":"MEYCIQDoBMz3cpR8p8hqYq1TY7iyrgZxD5hX7vND5setVUQ0EQIhAMAajKHgSBwdIphfearyoQ+NC1DgE75ZC4aoLGjK2uS0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14844175,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpKClCRA9TVsSAnZWagAAJPgQAJug7iGuOwHdWJ3MJU3Z\njlLTBNwLyval2owUyiQGDWz7uyHKANU8tFxyL8JIZ70+5zmrsp2Suwiz6CKd\nKERGMwgvwr0vQV+sn3R5VXllrtlFNhcUi+M7GacVCmk7bempXS2vfEKRCJZP\ng7A+lectlAs20LHGF4sC9R8psAu+ueRIOKBym2VKlXgx2ITdniAw2FrzSI9G\n1TiKjBd0r/jJyvYYyGoYCjWnU4KkxEWjCX2P8O1J5RzG8zh720L74KnjnAgk\nusWfW3UWT2TUehLyGDiZ/sYwhX/YsDiH57J7dONaWnz5GUriZ9+PRxzGDLqQ\nGO4jemflX1SXIC2Ig8zt2GqUf2xxhi0Wrx9cNuxYsyBcPZQ5eeJfWEZV4nwD\nMrE/jLptt3Dd45i9jmI6WsyVIFZGPAOAPeXZTrnp7xhFPWc5lT+ZTY2S2Z0m\nC0d9x3zZ/ZIfPgwovJxIRXDv1O3EBwg3Xas6WIOIZYtKUBamqH8HCq50R4k1\ndx7Mcz9G7qLPUh4AsoNczeuQcBgjurMnlmTEm3O0cwMgTCZdivAVErFMG4Dp\n9vNCrLjKu7jps65XyW9wBwOq/lmK2MRIqFTZg5L13Q4ZogaD1/XinwMsftuw\n/PSEn13URgIBAoqPJ4CLkj4w7tZ6VNzAzCOpuzK8lTY4Cm/RzWl24N09W+sJ\nFA7H\r\n=K3Vr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.4.4","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.8_1638178981154_0.20564836021197497","host":"s3://npm-registry-packages"}},"5.5.6":{"name":"streamr-client","version":"5.5.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.6","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3526c3ef9e6f2872272cbf434047d1421104d5a8","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.6.tgz","fileCount":181,"integrity":"sha512-iWLX5SumVvCzPtnjHu+FnQhQs5WltCaIEygDOWKjgxbUWsfejxRimzaKKD6ORmAtfwMGNktfoysVV3XI8mwHow==","signatures":[{"sig":"MEUCIQD/EjYCIO9bRM92SH+uKYpcbaIfAtsCLano/8hOVKL7/AIgHYKbXux5c/7vwflQj9mUP+tNwL7gHwqFJngKc1VE/nM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9022969,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpNk5CRA9TVsSAnZWagAAtIkP+gKbtj4bcZEuglUG0jc0\nvhAxRo3gOtfwYT4Mrxzt1QvseUQMPxfRZYzM0dSP5j3BtwNGn+D2GCLB+vyr\ndGocS2NRbResa9HScFwx6Tm4Othz8au7ZJW2vj3iMy5RFFwhdolm0Po2S60o\n7gkiUvCBr3cikCRKuQLudoObjLFF1e011yMdaSADgwlpj5LDmIcp6g+Ix0h5\neqWpxkMygWqNAnWw5fWkZ/5dWdlogGsy6FpHow9i7+OAeKsGD9vWSi8cWSku\n0gvb5kKPwvlmMl/wiaTTHkiXPcI3DyZRn40iu2dKLh2WsLynd3dQSKLfy9Ih\nnV9KGOvd7CzrdOGCtUV4lqelpAAAXJeeI9XCRgZyADNAUlVTczKkdGib7t26\n8gy+cU/BcjMnC7AG8zEXGfBPdTxQJZjcnHSDgCJwgO/WLAjd9x4JUsMZ9JU3\nhcrtRJwiY4Gno0i1KKB8zh4WegbFJs2rW9/N+R0NEUVTaAFAjm8EOb87+9JL\nVjTzFeVXEzFTQo5nTriEz6QNvxnpikD9y2hmzLfkQXl3nefmvb5ymQj6ZB/P\nLfAoEcyE+fsgRfcnST2moOXMFtdKFVquyQQ2J6T/YjCP8+/3lfdAd+PP39ee\nIl3mPZDGrbouHBopfw/HBwUxOsnSZSEB0nlP7aaSTYQk2oG8MXt181jelJaz\nWST5\r\n=veWN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"687e39b2aba81bea935d93ff6c29b01c52dc12a3","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.6_1638193465294_0.7616251594539347","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.9":{"name":"streamr-client","version":"6.1.0-ocr-experimental.9","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.9","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b700a51ae2115e08cd23bccff79f9b01facb12db","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.9.tgz","fileCount":236,"integrity":"sha512-C9wMvm2/zdpgRFXc4AujKKS81luxmxBuR1Gnok17pOKPexFi9Ti3uWjdb8GMythWwSKitnZJtqYQeIUXAkrgBw==","signatures":[{"sig":"MEYCIQDCBDFDe4COeJbPTRQ/s5Z7MITUari+Zd/IFFxcKMkISgIhAN6KPNFxLP8Zz9eqjUDYB+28vMX+e08r/ZavHCQRNve5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14842129,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpeObCRA9TVsSAnZWagAAdqcP/3IO+iSClMdnpH/Y0wwB\n4KstoFE67JOEV37TZrbK13R2mIl4Imeps8dgXnRP1HH8xwUR8aU7m7m90e16\nLd9NBdZrKRrJpRF+v5rxvyhl4NG8M2WJd/cQbjXBQkgMWkTPbbrrXuU32wRi\n5NKqAYeC8g9gXau//crZ9wt1O1uaGOeF0lfSE8Wk/niektKlxmxqzn34ASxZ\nvDES612w9AfqR4E6fGiMG4gNtThRHg5rVrPcUfElY4enC1llTQsOgX9FtL40\nBTbpLJz1afl5bNWm1+2CvzyerpAPWUpBchAdiWzfo05RYNUbpm9D7G4ogZDY\nOuRjXL0xVA2Yl28zLb0vo9Zg7D3T9TDTBBT1zZM8Syt3bXzaJg4SOlR7toIT\nlrh6RUTdxy9cHGmdzOaMLSNwazU84otQhBAwahsGFL3dYK3LljbzfdJ1Fbu7\nQX74i1tUWcwXDedTrNpncxnAGA0RSCQyenwJy10Pkuw7/vlbNre3wbW1Tg1X\nPWWakdoeJsbX5Hwdrzb/GtKxbkIPj29W084VklHuxYPjxYDBpnfZqdyilCqp\nKx2jRvRuqOeNHDzpqmmqedoFsCXFNEFnVs8gbrwW3l+wm+r4zHVs0bIgtXs1\n7abs9x6N6OIhBPFquVm+RFQQcyxxY4r3MqItJKNscxfAct18ot0ptB5Pq+Sv\nFRr5\r\n=MhFV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.4.4","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.9_1638261658984_0.6261959554798935","host":"s3://npm-registry-packages"}},"5.5.7":{"name":"streamr-client","version":"5.5.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.7","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a4a9ff714566c8e1934276789887afecf4ca505f","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.7.tgz","fileCount":181,"integrity":"sha512-qlCpTJMDEPeqlLdXmuSpa98EzIakAeoFxU+8dKJs4wBRn09NzoDB6xRZJB/IVRaGRC6jyhaAtyz8fWJHdzm+nQ==","signatures":[{"sig":"MEYCIQCXkg8eVKq/r6laQBBF1B4lfMQVMcJD/qRT+Eez+TwF7gIhALvA15WoEXTW+jl1wawl3H5cMk+m+LKzg083Jja1zukR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9023826,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpgxpCRA9TVsSAnZWagAAHDYP/1JLnAIaZhnGPVMMLG1v\n9LH0PjA4V4gwsIKSb64MGK06+D04S6qloRRN3t65R0V0L71JhN3riB/b8xr2\nHFD+vokmfD96MxSmjtOQXN1EGf950N5Ve8nVbLQM03tRBEQeaqFvlxIz8WGO\ncJB3z35ocBlKab1OBgpAolRjXyenUEyA3UT/knD68SaKOflcNXQZb/+gyTej\nYBMu3RpljXqGNKG0v3i9dRnyjgSjGEBvM3sr3XWM8KKFhs+40eXd1LowG0DF\ng1Aj2E9mGK0t2+WMb5BRew+L32DUaNw27fxwU/JhLAdHaHCWjM1On7jOlCdS\nHlhRgc9DZYs7mnzkptUCCWfIBi2YPcq5Ohj078ISv8/S+gSum+PhtaWJpthS\no67YtpoJtC1gRLvNDw47At6TPdSV1JzARC44JnV/frT8Qz70rxF5xmmZWjEb\nU0couHkH0W6Hul/kzmO9jwLRra+PXUg2KNpMmzIctH+Yy4c/08u9xEQkm5Vg\nylOpdlZJtKUT25EaOoxtW/2fpkoXxrx5ZWxaSheA6hRXsH83MQwGRPeMbsie\nEYpwD+dvRtR+Cl00wjFoVYvl/DIzb94GHkau93YQCESLcGQjACbuFnZTkeBa\nYJD2fqGFp4Pa1XYvf0sZJCQYpLlhst8bUCVqGPiCrDFTKO8/F1kOE7++WJI7\nfL7R\r\n=gfAh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"46ed7e6e15e6299c9c780c3e1fde4ff493b8df9b","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.7_1638272105080_0.8522879584425063","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.10":{"name":"streamr-client","version":"6.1.0-ocr-experimental.10","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.10","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"74e34a6b9bb886d30ee61531fe0b74c345c89bab","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.10.tgz","fileCount":236,"integrity":"sha512-UbG7LV1HPbJaYkiUva9Ffz+HKcqN1VP/WU/XhmnQV7bO4nM1rLLLKhr08wq6nLWG3NP2uOoSJaEjXm3JLd9LQQ==","signatures":[{"sig":"MEUCIQCdOeHG//CKbXJ9WzJVhoq4tt5xPtA09kngT134rIxezQIgebWHaaMWfBub58mbrWs6Lc25b47Yz93phIChnSxgLkE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14837712,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhp0vsCRA9TVsSAnZWagAAQgMQAI5MLPTCRMbgtDia3ICF\nN5buC3wXRj2ma16f6YP13yioWEY+Z+2+BHRqi3F/xs/Wl0vBBOb4OKASmDnl\nU9ku+ytaqbI4uS4f9BhliIOHsLpzrqzzvaxCYWclFW0SNcTmSZa41JvIjKAH\ncVuXyj0/sxSOdrQZ9OirWwSyCgfFDBXT7JHhmhP35uIn/A+qsgV8i1+q507V\nG4gfnWm9kDif7du2GQq2+RfOqzvzmbBODrB1/E8vPd6U5d7gVZCPH2xtfx6W\n6dQoFgLR34Vm3VwK8/IVvAo7tExvqK9h4Fv6COzRFvDyj5FzfQpxMgyTGJMd\naoZqoWomZT2d7dXsRJ1dtanDM/LXscSuDYz2CHtuzHcbZd6JhwS2KquFr89v\nbmUsdTmXdnuwCwMLWB7KzUJ7uJ+zKQcugUAruwClS1JLwEDfhBvGJ2FZTxPD\n9gKwHGrdgtyntVVVtlg6zYI5T5u+MBOi+AMcPQGpbTElm2zggRZjY/gqAmoo\nx7CZzYD84HD5xfn4WEq1MapMaRx8qFRov/NQCslNkk1/fAExUOsSGT6kKeg8\nWXyPp91vb/tJvwaaFsoUq2tFZ68m4U9YPa8XmFtX6IUYG8jklcTJ68TgW1ng\nnk/Ee6cDlWYcKbEBpnPdVxjaxQ18AmAC4+qzEuFafwjHJsxWCbITqCQNaQyA\nhvSe\r\n=SPxJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"7.17.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.2.0","dependencies":{"mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.0.2-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.4.4","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^94.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.10_1638353900460_0.23433215950162323","host":"s3://npm-registry-packages"}},"6.0.0-alpha.18":{"name":"streamr-client","version":"6.0.0-alpha.18","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.18","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"4e2b6bdcb89ac34bed55102d43711c8a0d9ecb34","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.18.tgz","fileCount":235,"integrity":"sha512-VmgUn/11UGRF8m4Nz5WHwCCWM+T7fy7ovcBF4P0C6U8BByt1BJEw+w9PQ/YVDonCzKwO7+WZbutFgBvdxnup2Q==","signatures":[{"sig":"MEUCIG5D9KdNWuyaSVGZT/A7kF1Ia4TSvzZYWBEHlwE/XilcAiEA/0ePrgmQRTtN4B0gSC+aPbRl1mtBfKxIf3b3v4W9YwQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22638905,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhszSfCRA9TVsSAnZWagAAy6YP/3WhwDYCMLRzUVpighdf\nxRoGre3Y2+HyrWBZUx/YxYydSxzWee4VzkhV9WnLHW7ntJGF3W2hGkiKlORK\nLAXL/lLLHjoloysWb5Oq8NQpkoXcZOjkf2Caf/upsRHdRqmG7tUXeoWosnBo\nKrYHhkLeMKQrN2F9Y/0eFk6768WA5eTslSXDaop/wZcepfJSGMxrlDTAxRoS\nxU1LOVsBI2BigfaGrjw9748IP349xIcCYdSoLT2J5KQaYEy29W8bdLsHGaKo\nOQYxyAj8XKjzhAUdBqOIGCodOhOzvTHM6XKOIZgcvCQeJ+dspl0sCLVqJCBM\nvLy2AehWEDh2riwS/LAvJ0ra0EllA2f7nwiuQPrkOEUJxO6Fi4kV32YuC8eJ\nmEKdd6bKqep1vUW3W3sBTry5RTFxCizL58SqpRhC984uP73xEU9DfwLkPmn/\nWvYNRIRn3tfNTURcOU2RPnApZ8SJ7XSarUq5bW6TWW7vkEtf+b5fqAmy8QA1\nOmY+RX6aFBATPTAmozQAfYsS7FmVM0u/Kj1N5HaMroS1S9+UskUpGxR1vqZ/\nDP7WzWPRAV7rSypd/VHPuQyfge8xaniFOkA4VC1ls5ok1QeZqxvpMEqZK2+Q\nadC4vBiBjDu0FUjSifIZWhHt5TUFHC2vOOFC3G5f8+EkdAbAtedSyF3NrvKd\nfhib\r\n=G7M7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"6e2a32a6d7d815b408225cf489f9e40d23cbe2e4","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.1.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.1","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.18_1639134367469_0.02599296972095777","host":"s3://npm-registry-packages"}},"6.0.0-alpha.19":{"name":"streamr-client","version":"6.0.0-alpha.19","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.19","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"7f2960aeb51b1c4501ae0208d07d5f00c72bd3bf","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.19.tgz","fileCount":235,"integrity":"sha512-6NFrpA3BTLNraIVApi9K6oqPA6lH2c+ZxSJAzKTJTVUxm6U72/g6hDnan/flAwGeNmJ6t8imjrtTRysEL36XIQ==","signatures":[{"sig":"MEYCIQCsgVIr931ZEnuOFzwWJys7jt7hfEhuuvfVq1gPZd9UpgIhAKi+hxxzNzS/0xsXyPcgUov14bLKCilJRot5Q2UTj6HA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22638905,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhszmCCRA9TVsSAnZWagAAxq0P+QDZoCJfYivK+JnQsfBy\ncNRNvQ+uPI/ahv+Ft+ayYF89GpevW69+1SXgFTmnuozbQMkD153+areAmceb\n/9bd4MGicss9UcLeyvcXxV6qV3Z6rd25hw/GOyl9g3mmsXnA1fHYxLCWHQHR\nvul/pwUeU6LsF1RePPZ4WvaZE9PYPeKoAHmCtMVvTjhmd3oT66OqvFUaixUU\npqtds3pPXGK81SfvTU53+WQRCBJRmTwmBWdwSEOW2FLYsMt/ttNdiUNO3ZIg\nN9cmZsBdCE6PTK1qjD7qH3ZhE6KCqT+2szhMu++Vgaf3uCBpTv+naDW4Rhj2\nL3tMzVrokpDFhdeR3CttbXiWJ4cbN5M/neGyFKe44bNSz+eRC7gDgES/pMlB\n2lN0cs74O4sClrZnjuO5FYK0rQBTNQcNLV6Q63HU4wV3DWtNMBvHq4/+H43E\nipYTb05DoIDsW4yKLWBqETUreXQYCtVAjy6u726g986SKYDBs8ztcBxvPnyv\nal2xgib9n3HJATxVWfbwJGqUjdXhZd/HTpXVnJK/OVC0GPQ4MeBrgUEaPsO/\nAIlsEOf0FfB7qq3R8CvF/kkNpvPmKzMBe4lHwK7q4ek57Sq4yGyI0g9/wyXa\nr7WWY27JBKsAAEKiL9Qekl662NlCQKstwUdihZPDBhiId+toE0+bdoajL6Su\nwy/6\r\n=MKvP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"902e9c62c9b9f96808eee921a8d6cfe4ce7ddcd6","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.1.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.2","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.19_1639135618596_0.8842873111850955","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.12":{"name":"streamr-client","version":"6.1.0-ocr-experimental.12","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.12","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"fa4c6850257505ae146b894126ab1f6ba32e1021","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.12.tgz","fileCount":238,"integrity":"sha512-aGzWzmr5F4DjoXWZA9g7v90cb+WQtWlMDBR2CyjVV9SGnQw6npHjLec2o3GFFX3tbwlGFfMeNsNUXBuw4k3QQw==","signatures":[{"sig":"MEQCIBlSDROhlpnr/FkWhjcp63Gp/dK/Qp6Sd2c5RT/LFr9lAiB2SZ52W7B3FO/S3ZN2lGbNmdPOVAEAnnPRoiXxJCVdkA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15679142,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhuIklCRA9TVsSAnZWagAAyWAP/iwCdMcoH1stbslJ+qqe\nlXcFOKCNCyIRDnIFhtUOs3vdjsDuBRqFrCjPq2h8QjL6v6pkQHCHCsCSRaPM\nXR04cBSVHmXkbz1Kftp03MvF7cDNQdi+ocm9DLRDbuV+vijdhiy7q1Oh++oD\njdSOXbY0h2B5L456G96MJWFpWFxDObc3nDAbEFIoqFtyfkGfvOZWjz8Uc4Sq\nsePXtKkTyY7d0u02+PdlTpoaBw/9MKeorK7PHkVI71R7lKUYS3mmnhizyvVH\nfRjm+ddS4V8Ry68WD3OihERkn0WqTr7etQYMyGafGKr0G5kO/M0mUDXOnD7n\naUlS4Jkr2NLGMxmL27Dup5rb/97ba4L/vt3hvH84VmtqvcZ1O9CWakTwg+ji\n+mA4rcjhMNGpNBczEfdeGxoN9dUM29sUmA2brjBMuu/4fy6aVeR871GFbweS\ngVP3P3KfwRaH9zpIkWnV6muVmim7zZ5h8uhYpB50A++4K70ymbxe1xYlrQqB\nkE/PTpxEuxxs0tfIwforg21X+1IcwEiGOzEIvMrIE9lxqX+sX88Vg6WsoTCh\nupaLMbcwlJ4xWZiP32WgyxY0WaPXWBvRwsyqWty/ur0uA30X7I7cr++jikS0\nhxHlN/olZouyHPEuoWCsw16/aiPGv7Qawn2/G9Ef+i3x+ScidA7+5NS1uj57\npHL4\r\n=mv+H\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"87b671a83cd2c40628a4bfc6509bd08b352c8282","_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.1.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.2","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.12_1639483685256_0.7637208092812495","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.13":{"name":"streamr-client","version":"6.1.0-ocr-experimental.13","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.13","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2c34ea34c981fe9b5aedec0924a2668218177a40","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.13.tgz","fileCount":238,"integrity":"sha512-gKZWQ/p2DlwgJZvDTcj14B02aAH6+RlzeYVQBeyHsUvOdkGxuWUeL42w8upHozy4sYKYcWouHqJ+1xpJQ/7bMg==","signatures":[{"sig":"MEUCIQCCsvD02wBRpqEoBUHaONggTTOUb2MfLgXT2UmEoRAMyQIgSRaTaTwUaIWQreE+hFwfC5Zg+uOxEWjAXw0EDvltUnY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22973688,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhwKZqCRA9TVsSAnZWagAA98EP/3fH1aFPMCFqFiKW4RFG\nt7x7bn+Y0z7AaIXPM2GTaGMVRBhCoH+l5Rsbwl1uBfNtNCtmk9I0UlPgKZ/I\nMKujwtcG0kQ4m42COPYN9+b+8O2KeMVFPPZJLL/v5DsAlWSGaq052dXGbaR+\nJ2ffeQRO/FDKQ3lJk3I3s2lnlY6q7CCMxlIIRDhE1JQaxahB9EA5umzZLvuv\nOiwj4c34mEPmsgRKNu/6mL8WroHYs5EOMX1sbCJBYrxNyxmv4jnrqfLN4/cC\no3P7mSacTXOObnx+6GmRIIag1XfEVweiXtajDcdl3IPkIQpXa6VWaY/FfczM\ncymgFWlV+YtwWt4MSlngfI78cUPvPJQkzYeKDPPw/Q59DlMAkyMXlsv5x7yJ\nBIV7yKhTIggoyZuOX6d80UzP+nbujPCNwiPjxpS6aqPmFxfXSkf+KyjhYNKS\nUdfrllvxYvfIOQOmsJm32kKdPc/VoKXrOp5ifo3NCbFXlet6sCda5g3w+xh+\nzIF8vVtVJWI11DhzEOMeDOWVtvPb3WXyxY3Wd99vicSksdEjvrq2uHQfTuxK\n2HWTRGYYSt4Pi2A+SziU1Y1MnGmKLwwdU6AYC8MyBHO3Wd2K7Z7G34+6D8w6\noqI1k9ZQ6pUAdZGHEXbJ7IO7UPfd72BEjbACtLvrT20fclo0H9bwnPjlDmuR\nUc/J\r\n=i5se\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing\n\n1. Update version with either `npm version [patch|minor|major]` or `npm version [prepatch|preminor|premajor] --preid=beta`.\n2.Build and publish project\n```\nnpm run build-production\ncd dist\nnpm publish --tag experimental\n```\n3. \n\n### Publishing `latest`\n\n1.  . Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either . Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"6bce0f09e6487766637407c3dbc5ac5f3fb8d56f","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^31.0.0-alpha.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.2","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.13_1640015466473_0.9882437943754501","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.14":{"name":"streamr-client","version":"6.1.0-ocr-experimental.14","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.14","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"6011e4b368dea97d85c8ff8f43d2a6e809896686","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.14.tgz","fileCount":235,"integrity":"sha512-vR8bbewOEL9odebLRBNsfnn/5wgZrjqiBTBi9+FWTURH2y+b37B0mZDDW5hApkC2oeLQ8EqzNaAlt4eqHwgCtQ==","signatures":[{"sig":"MEUCIQCIE/4Vpxc3ApUy9OatqQMqaeKQvMroAjn1d6OIPu+Y4AIgYCVLxUL4cwrS3yJvTHTPpV1O6LtBito8ciKSN5R6F5I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15704235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhydApCRA9TVsSAnZWagAAgC4P/1810perpp3cK776+mvV\n6JLT2UhbDEIDgXwSqQIormu1jntNOOe2pRghaXhB2txC9cmX5BpKb9q6YWDr\n+47NP9Lw8z+UHNRRpI7ndfBAX2x0f8l0QxUPqoXvac3vdI9E9okoWVJRzRqH\nqnqCahIkte9SrZGiX4A9sRL5bNpk1ju5ZafvI80ptgw2axEx1B/2yzN9PqJB\n+aiMLWDEyGTooprGlk/ATj6biiT0vS/1qYlEviLr3og6JGOsLv6rGlB015cb\nf5D23xNpzIyY5RONhpQyc2pBlfTYZ3XIMrjp1NMakFHnB1x948aUnKN/I0CG\nsr6ZlORv/tLrw6gFgv2y61gZAEM5Ca7tJyYROgmnqDPPMPdW7DYz/XnA6mqk\nxNufFk1cdSkdF6Tw/OqR/Ng3N/xazzq3ctmGjm2+FC9nu/f7hx/LvrsNnb09\nTcjHU0g2FtFkL7ky6pbvFNnyte6Npk7yciQnCCRZ/wDYEhIjebFAtzk/LubA\nAifasoIgJz5RAJKRWScPO3gqTq4MQkYzxRAr6bLdT55I57uMMvJ27vTSBm3X\nZxx4zeMfWmH5vNsT/SSvkT8blcR9IlrlDVH9cep2KLQlePcfvlEr8NSeStP9\n/7oXjJHMxKMC+Z1CkHQYZBwpk2f5RJ6XYU4E23kFaPPrfxtfIUj9iWTcK3Xq\nCEX0\r\n=XJcb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"731e78b5ed97f8748264eae99e2e802e939dd389","_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.1.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.2","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.14_1640615976492_0.5864236691044844","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.15":{"name":"streamr-client","version":"6.1.0-ocr-experimental.15","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.15","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a0366632b00874a8cd51cc11abe6e5771895a347","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.15.tgz","fileCount":235,"integrity":"sha512-TwljdemuqVUrgB2FmXLm1kREYTOPQU1zRAOmTehf1W/QPvj45soQC2Gi8IbvOG4g8ifmjPE/jvYlT4C8FzCZAw==","signatures":[{"sig":"MEUCIQDUENpUBHNL806KxWXB/bsjTJT5pjFVQ5mvhPObmkQDgQIgVJElAkVLIXd1eO+NiJZsEdrRx+zJqgazGY/rCWpdbfQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15674925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhydHRCRA9TVsSAnZWagAAJA8QAJmVua+fXMTbxnDXAYTg\npAOKOov8F/CoSCdPuYPGzkKgAqf5P2rdDJYDovx7D2ogvk6W6MYJLG5SFfDL\nVK/Yw6Gw6Nb6UEh48dzCvzWStlLx8Yu6WS9j+llalr4f8PKr3q0MudablKQl\nfcFt3zr3ncKX/tbFBtjbPtof+EatPJ4PfYPAb2NSLyV/DfY6LXVDnrq9xR88\nwdZ/8vlCFSH7w0ZgVDRhpx/8FP+C25rV5EFqeqFYQKwv2bsWgseKRD0qNDE7\ntmY5UBz0jUjTRVLmeeu0JRLdUZ+A/aC+7NuIs8UPsC9OGqb8glZ2aRb32xsl\nmR7yuDcjEVeY5NY6xjVRjOHdvWeBIR38/vwZVkfX2h+qQsvf6MlgsetUfBOc\nwvWoGfujii9IhpGQAhcxoso9+d29GGOuVPVCCfJ7l8Rrsn93GzXUgc+K5hm7\nn96FL73WQVayPkjL5od8bUV8Sk0MnMnLmfpKe3ymZqS2ThDrSEjPBlxQz5FL\nLgJSZVDqDEv8hcV0ByFw+zgdRvt9GuQfvqeI+xpKtHKeBTJog0XRquRFRzhB\nV8aMRPQ+bmRazmU1HdKRWBJ15UdFOHBzXMUi5B27fi92IIcoNwDgCBwRWImb\n+NFnoUbk0iCmEuxBo3fftsQ/6OmvX7mGLVF7r0urGUuUUqr3CazuOhjJmEu5\nVg8h\r\n=Hgj7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"cefce456538f70bd7876e9299874583429033e2b","_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.1.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.2","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.15_1640616401623_0.49115737028467565","host":"s3://npm-registry-packages"}},"6.1.0-ocr-experimental.20":{"name":"streamr-client","version":"6.1.0-ocr-experimental.20","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-ocr-experimental.20","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5e1902fbc6f662fd80780d775353b342d4d8fc07","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-ocr-experimental.20.tgz","fileCount":241,"integrity":"sha512-Q5XPxb+96fYnuuBrypC2KzMCl15RK1ySdHg6sPGS996/S7mUI29yQHKR2OXDJc5TquqDfOaWsNwR1qKq7trBOQ==","signatures":[{"sig":"MEUCIQDlNdDW7jOs20na7ms68lj2p4QUZ/S/Uzcvv0eXxWqrPwIgCS04Ciu2tJH1vsaRbz14BkfCO6YOcZdkxMUjBIRrMC4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22269402,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh5V1fCRA9TVsSAnZWagAA/S8P/3ItV+rPVwQeZML2xGgp\nA6MuQJUhCgIjwSeU1Ual55eGMJ4GxLJSCMfqI77nXtvgc7UNPCgEyutnu8AJ\nbmEJzpyrp1l1ikSPM5ZcE9fZ5QIjsRDmksuq3+ePFWm94RpB9trg7zI5CxI7\nXPp0IaC6frSjnUHWDjzJ5B/1/RgoNqb4who7IjHeBjfLEs8tmbDa7pPNQ1yw\nF5Ntxp2CS0b59Ov3ehMNAYq7AAvm3T2xqKf0s3OBO9fClTzzEsYGvlDiJuWD\nL+gu57yymMmxZegEmkNusypzHsS6ldF2cLkW44mjUm7GDdq3Gnf8IhHa9d6O\nNDvPO/7KQ80ZINFLCGp2zMKzVvrJDwObzCFJTkzv1OCM/Xc1muvm/JHfe6/d\nnIS74In2eDMUbC4rezdNRTLN3RmA4Xq+ZLhIpDq8WiEIkyDtn43zynATTZRQ\nUEmvwxs6mZzTNRanAqKAMkv1XFUxlqz0c9iWywdLUQEPNh7lAEwJMg9JRQd/\nMH/xG4/kdHor6BAwlwVvS9Ee+IgaSAGJrzDYV/EhrIn3qEmvtK95/rUvAJaO\ngEzw6g08pi6NNUHn1yQhHC94JZI0jTlWgUnB4F2H0WpK8SyVblRypUWM1Gay\nEugqGryp6/7zKBmX44fFQr4KjEj8dONLBnTEikK0HxiQJlcF48aT/vCyWfhr\n91th\r\n=I4Bd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"02fd8096c3adbc4b8e9660469b05fe3474abfd62","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^30.1.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^9.1.2","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-ocr-experimental.20_1642421599071_0.8066642111393099","host":"s3://npm-registry-packages"}},"5.5.8":{"name":"streamr-client","version":"5.5.8","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.5.8","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"eeddeba128e4107a8116d78e73a1c6ef09329b42","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.5.8.tgz","fileCount":181,"integrity":"sha512-WfzfjFYhqGBuwaz64VJAoeNnJoAw+imM3tz/Qx5unvi6Mu5xMS/3miv3G/Eg3WFeonxEsbeRAV7CSUulqhmptA==","signatures":[{"sig":"MEUCIQC2kSWAzuPF8BBPN4kYmlUZylQLKo0vE41GiL+FeEMzGAIgNVK3DbPuc5tPpkjnTyHaclzI0aL5ymQaqkHyE8cD5Ro=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9023617,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh5c6uCRA9TVsSAnZWagAAQdQP/0qEPjU/hN2DjL9uMRd3\nw2+6YIN7kavHyK0mNNuZVtuHPcP2PPCXRzZxEYhA6/2OXZvpCitLPm8Em3VL\nEf1A/85rxEhgOVA4cHn1e5SufvAW/Sgy9jqsWLuWi3tRF2YoqfrFMgdDR/Cd\ntkQmU20jadNo19SLleKePa6UVq8mx5302SlbJ0b9+A4j+/2sRW0w3yqxgvBJ\n3wTWaZ08sIHRqS0JBIl6gjNUlhsvUAgBCnCZWaMzofK+SZoJO+lsGdMjKfU+\newHRn506+0nHfZZGIBReE0R/xyvGrj0RMADv7KfZDzj5szDcaQa3zJbbYMcO\nf7flojvQQsBR9jDwNiqiDOK14Lk4CBXMOLsbazpOB4+yrDUu7wRFLkOngVZh\nEgSSnW2dFgFQVNO4ZHvXgM8PsTbLVG3/gZtc8JJkpPuYemZ9wMqFpauKqb3R\nV3H2lAMUsF4O2R+dFMTTnUBAnRSXEqGOumUdeEnvrzbCm8KCiCqZkl0Vjtbm\n9UNiKJHhTOo2rhlyZ4cv1AtZKOvqbnnphelTJ+7D6ozbSzy+mnL8HBO6u5Ok\nI5iOwtpNCpKnJ148RbmwPDLlTWf+JHYiQ/FnTuli/uea5gfBmKvraEcI1bFB\nH2vZ15qChaW76tFA9xoc+iICXzGV9qDWyaPaZnsORQ4kJf+QIPuBHaaOqKCe\ntJTi\r\n=rZYN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"851a90d40e22cb5a5c37e3eac19f25d8ff8bf29a","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.1.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.5.8_1642450606303_0.5294114120124871","host":"s3://npm-registry-packages"}},"6.0.0-alpha.21":{"name":"streamr-client","version":"6.0.0-alpha.21","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.21","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e5c56937e87cf83574194c40b20a68b77828d6f1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.21.tgz","fileCount":241,"integrity":"sha512-ANtyIW5XNfSERWQ6stK1OQtC859cx9tWWRPQ53YNaWcUh4tJvyxcxZ9M7eKbDOfrRiYwC6HxuEahqEzXvPVZcA==","signatures":[{"sig":"MEUCIHhkPRaqvVYhEFEl/xOgwCKl2ya22LUwkmKBlsRIOqWnAiEAy3sQTM+aPm/LxdNFLcdsqcJjYXEIWwTFjqS3oixFQIA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22364892,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh5/n9CRA9TVsSAnZWagAAPW8P/inAIPaU3clRW6nQHKeu\n48/cLvwOWzevSvlYRltZCMfAikk17Y+I2sQ3SrEJE/3ZaO/rRn5BfSw6aPod\nF2mFfy/xBCKkXAeabVkBghshTOJ61pmA21Ne60cUysnnVvDxDAsMhLx03Rv8\nC6vHO2KlqWQ2YwwShfqNewfjGtGMO5uZgDrm9acIPH+O2FwARBfw74CjjFkT\nwbWPhtkaijHtXHxBUGLULtY64EdRLQaF4LSspmJQDaWj9yzM4r2uARITJZu8\nFdUGHBd5ojeDKRGpgzDYUYvRHyxfTf6oApOrnbhD8PCeZuqtb8YokflEHkY6\ngiAXsCnz7Aty7P3RLWEO/3yXN4L8rRJSn/lZFwL6TcpkOh8KXsRcSsjgnyPz\n0/qM0lnSAUlH2ZB4yTcCd+Rte/FZvLTQR5AmWtdfoVgOBoNFJ8KT1pxxQYJ+\n4jnB27T3DeiADXk7HpT51h2BxlQCu3t9aLnR4OH6fiwWZ5iRgFUCsoUDKfwl\nXu95e2Z0VRR3tqpYc51orNgWsYTl7pWzU06CMSrlHKg6JowL4fwlI8m0bTxL\nzwdPcE2nrZK5AoVZvUY+5qm/Q2pVisYZREoALXpFAeTzPIIzQLS1IPrkfCXC\n8FRxnBcyo2rz57MnKNPtcepuoFhDz22Jw52YSrXhg0bragVqyIgkwZYMS/Y+\n42pE\r\n=8WKo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"c3ee56b383c3cc2c7a0b1eb9d12b0b739bde19ef","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^31.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^10.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.21_1642592765238_0.3669247610961044","host":"s3://npm-registry-packages"}},"6.0.0-alpha.22":{"name":"streamr-client","version":"6.0.0-alpha.22","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.22","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"3a52dc1996c17c6d3da534f476da9884700e3ca1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.22.tgz","fileCount":241,"integrity":"sha512-R1BZ2ULFjVowWQjHAy4/T0HTv1i2FPHHy8Sl2URnFtHmv6Z9KMUTgJkhX4p8NkdSForJAOOgzb3r7q2J94rrJg==","signatures":[{"sig":"MEUCIAUE6YsrTjcLsyU31cNuBILRAV0AOczC9X9xdctFjmLqAiEAgdPTEMW5AeKnRxaBHu0yb29cM+JmHaQLbQLeqbg5LMc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22376444,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7sPDCRA9TVsSAnZWagAAJxAP/R8sokHh89aN9afa4nNl\nw3hPpiGMuKjyicL9fzLrE4dy70W8+y0QD0pFswYGyyqfpYall1sfVBFjyst3\nxHnTGLgl25faafUvGph3nkxefPEwnD7qv717YVeGQF+pByaTu1ewxTjIPToF\nQdKbQS9ESMAL9j7iGquZw+sRRCfjSA/DqSOsCD6RPvfNh4goupHOxMjbFxQn\nnwRVW6PxROfXPLg4F92hKIP9azIkRWXxGvVPQXUXEbVyDJPo9VV6mIEkEods\n9lZhrDnBGcCXoR+SGwlwrsUkyJz3EDjWevoP4cuSAvMRmbhE6uBv730E0jDi\nbh+fJGMhBn8pwTwAEuvzker8tMM67Em18A+pFXPC5bvHcDSHEj9ErtKne1h5\na2LE+JkIe51JEz188d1lQcQkR8su8zhaj4J5d6wsRE/GeU7OJFGmyvMKcY0J\nmQi1jb/E1XWNXDSPFfRsaPRah/naKbiUq7iaUpdVavJomreRSOJ0j5o7xfme\nhJBMbSFFkTY6sy+AuiTgurGBQN45MMfTdEzCGWF/MiuA+Pov1axxW/x7A6RZ\nYOHxkWnP182kVFVTMaFG0WRPsSlXA9xBGWfrFURUgEZgJeHh6FtZJWbJNSeE\n+EKuny5PnMJlKFNdMskAupRhAE9CbJyQUBe8uXhIIp/OaILAVk2knlo6D1Cs\n1BCm\r\n=uCwA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"14824cdc4a67a9f5241a36e7ad781fb176578d6e","_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^31.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^10.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.22_1643037634823_0.22153699897631318","host":"s3://npm-registry-packages"}},"6.0.0-alpha.23":{"name":"streamr-client","version":"6.0.0-alpha.23","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.23","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"e958a8748a0bafd8e739ccae5285424a5e76de52","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.23.tgz","fileCount":241,"integrity":"sha512-2AriiF2EUDwdm+YSislBO2KAIlPuGnDNwdDGd931GSV7UPOuoSAVMnpzTwb1mqiDpkodt3X51Bf/bJYXkC6+4w==","signatures":[{"sig":"MEYCIQDMzST41gqvmzcWira+NsV1anuqsFHVHXcpQqKgtviP8gIhAL1OBy3YKKM2K+ET9Pj3ynpgyhhARaifx1oPjRMnALra","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22387306,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh8RsBCRA9TVsSAnZWagAASsMP+gIkdyOpV0B7tF3z3Zmb\nJFumtRPf00CWa44Ef1DuC51302iicqKPL3cwsk1n2SuyUED+20EGJK6bq+gT\nHlC3wwEy785HHDFlEyh15S57he22P3/7aOZltIo++/T8/yuG6i/udkH6YuMo\nvufrKreIE0SJQ0a/WPIacc0ykXvnZAJ9RrGDSKZKJoucOviQqjW4VHvHBEIl\n4iWwlh5fWgYQ2JFH5GSMd9I7733ta48+mBE21DK173TW3EQ+CpgjAqOKnCOd\na95jvNwsoMJXtsDyG4l65EgnISgN9zLrBFx2AeUplIKFRo2ggCgyG+4+oVR9\nbHedXxd1VbKHhepUJJAlI9biDBj1KcvN5yTAllDal/Ef1B6jTFL9P7rZqrq1\nREoEyGE5bDF28mi0ll01BGK+cwpp6WyIahbm4An/ejltUzshv+Aq/IY2bI/P\n5bfkLh68+KxrvjGbkmylEwl1tBEDlj8SKbcmiUQQ0sNDm2stfjCqpR1DtpLT\nJv5WWGEzPhK9px7BndbqgEkQW/Bx738iA8kJ6XLgLqBNozlaQH3+8wI8QgNn\nD66ZjLh/8bSijVZIkF7/ibKEmPmvkGnTMHN/QTknO102g9scRVmjUH+FVeQQ\ncAZK0g1ESnF/VV3UPTTknWSmcFb2n8xel8wn4hK3MNVOMR9u7b1wLz0SMZsX\n4qSG\r\n=edCn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"ddd963a311848a59af65bb076f7f4177722a1639","_npmUser":{"name":"samt1803","email":"samt1803@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^31.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^10.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.23_1643191040926_0.4632109749538562","host":"s3://npm-registry-packages"}},"6.0.0-alpha.24":{"name":"streamr-client","version":"6.0.0-alpha.24","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.24","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"b564c9987ea203b1aa68d69a5973efe914f3eaf1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.24.tgz","fileCount":241,"integrity":"sha512-qKdY80+k88swgYO8D3t455GmKkxRPxz+6W53tCrVmG+CSm+rgyD5EqnnaI0yrhoE04dERb0GkmZd1r9LGsVxOw==","signatures":[{"sig":"MEYCIQCjPlcC1jCyGAr1RITsBmcGa4Diivu+0Q88pjS5tImcFAIhALHpzdNoXN6Xjpm9ipnOOB8+Q2nqCoBYjhva4hAdXshM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22387285,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh8UAKCRA9TVsSAnZWagAAIugP/0l/V1KEHMmJYxw6oID4\nRL050Xg+qE0lk/VTAHzzV2P+BEZ5pOLI7swEOyGJM2jslXvHnNwMWlcIpHyd\njbtchGLWOMBjQeUJL1nDNvndspxWwA18Ha5+SgVSGagxBQN+yMkqHvl4f2A4\n3uivtnFzjgNTLn1JKKAf5Pb66QtDjPbhoQU3+eNaCcbVB3qnSeX5vPAy+INb\nZ0sd9AKGAJFzZ4NNd/kSXE0AvcinSJ6CdTbUiVJwSZHOggmroAic9Y89yTWP\njC8dKmhsnnOUdkbwdz+RNW+uxF/9YJZt27dfNBYb/75zWlRYbYRl1w3hD9OZ\n5/nHFR3ilaOwm6xsEaInXYGEP536FMfNMVTUcujiY8JsHybGCjXpoY81+9rc\n9/MWtTUDxEnpOam1d45e9O9/Xlx27WorSuvumC8r9carwKHtaeWtDAp9uYK/\n0/M271o9Ro0o2UkgKycWhmf7oOywpn4M2ph1cYwhOSnpJhL7X2itbU0d4LQj\nfKOcK+2/axVjUxgM3zUylPQmXjhCr0fmR0VYK7fCDYeHA7wv4MgL1eYqyx2C\nd3WPxgJMZayrsTHMUFrSjkq8viu3dBypsKKzn+I0CryhQa0A819085+22wzk\n6SBw5WxtQGZzgDgIGHx25RudnwoVWvy8SRudmj8mVBfmkgB8+sVhhO2KS/kS\n9+K0\r\n=Dnp7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"c98519e018741ef31dca863c3e56290b2611c3c6","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.24_1643200522206_0.14526527891004504","host":"s3://npm-registry-packages"}},"6.0.0-alpha.25":{"name":"streamr-client","version":"6.0.0-alpha.25","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.25","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"08d995f4011b56d437f9e1df135d064b477a6118","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.25.tgz","fileCount":241,"integrity":"sha512-kksBx9haxL7vVLMw7NDTnSbht2SE62Zr5VivKUVLqRMHZXMxVyzqq0i90RU86CpCWr+dcMz5zumJLdS44bpllg==","signatures":[{"sig":"MEQCIGvlZo5LyQWleFPime06/JrrT5jQXHxGzrDzXncTF7qSAiAsAWUD9LH1/MzkL8PVdjpKsHsYC3FSYPaJbpZsxhaIsA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22402254,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh8ZMSCRA9TVsSAnZWagAATA4P/3d6NHuZQy6dtS9oVLlz\nk7d/r/WANB1kz8j1V3AHFGw/YowWpgI3y32gHqrWtoxjYhABbD1sNPQPu0LY\nW88C12XwsGr0T9JVh/q8SLxGYVxrZr8agnoo0SfHYXk846zmA0raEy+4jdMx\nq3q7FEzdIW3MHqlNMJGMlAqi2OQbuKBvnouMUMbEsFqpTVYD7gkOdVBKtqad\nvB3ywak/RKKw5CHparjet75C3X10Y5bZ7WsNEAFeeR+iQD+t81aUr067nVJE\ntnZgwMpQRWA/Kf8Cvdb/beZ1ntwXQUerm1o478UL4BeplhULEkkO99AKkft3\nc+mNpN25uXmDqNuvrrIJlY+8lzWbD3RJi2DExC53MQ/uBlnaoKVIjhcNY8Wz\nfpUwTKrHGedxMFTXA33fC0ERlKs7r4gy660EkpRdc/CwJHiq9YIQKKWM0XMs\nZ5zEWWPRMOPtgner3MuBaehksvhDdS1vCor2R0rQqEhLce9hSzMZySUpxs0j\nYGNm6NZKLLOQ2P77ZNIUsXpSlJxmb3ej9CWgInyMKvGg1e31UAn6n1PkKDVs\ndV+uJ0bvV4LvOll8zxMCCb8Q8pvXcnLc0v5UwuVOx+czLcWYkPbgmgcEuILq\neDyhB9FYOOt8gGIn+FaxHOjP0vQQY6m0PumQPmyEr0fGtY/fAvM4xklxIL6U\nXLnV\r\n=36Tx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"9411adfd84cf4134c8d3f99ee156b22eed47bdbd","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.25_1643221777959_0.6639538581396349","host":"s3://npm-registry-packages"}},"6.0.0-alpha.26":{"name":"streamr-client","version":"6.0.0-alpha.26","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.26","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c8af54403474598d956cbcc046f5cfce14e2f984","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.26.tgz","fileCount":233,"integrity":"sha512-wpZa5u5qGfnchek5QP4viWoC0HwTiQSCwOqtV2V4XC/qiLuK+d5uic1Pl9CVhVaWXiMpIM/JBjU+itFJ5yFdbQ==","signatures":[{"sig":"MEUCIB1MyYQsNypkwWN6DZNamBmISuz/bHtN3GdLN0hLdEHAAiEAhh9t0KBLSxMONDiyy68KXK+tfFb7pTFJU56A26XfKLo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5567605,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh8tsZCRA9TVsSAnZWagAAHIoP/jRvlhHBgBdCMTXzWe0c\n+V4CET4+9R14i4kWnwwLCzJam1U6mpQ1LV9+oKFbQAdp4IwzBjzRHGkdzYsg\nZjuKwx6flFaQ7UHiSuxBaUhmd8PjJ6/DfxDan9dUcBh07fT+ge/M76M3z8Ok\n3YjTvS5JNEXzwzOqJaH5TY/TAcQV4TQ9yxcpxYyTukV9b3X+ybzknFA2MPli\n6ehQLcn8B3rfh+TWgwU2IoY4mmaaPj4Zyo1oBYsBtw6mYYU+PERtobua3oSi\nbly04dyMOiAtH8A3j5aoZOkw6kDQ7EuEs7ihv7KuTTPttmXQfy726jqpalXV\nTmb7V7kV9etCpIbyovCFJU8vNHvRL9cOzKt4ekAf+5+A1D8rjmSRh9fVa93d\nb7CMfOELyr7LdOu+M2aJ32g26SqFnJNDm1duTuJ22CuRoonh73pVlNfxsWH4\n1OtpleSUY0OaSV8X4yeGWny/AQzaJQsUjVSayEBBmoic/7Q9SRXIT0vZHmlv\nI67AJHmHvKHuCfyygz+gWnJw1zqJ0v2Blc6ivinbJQFuDrMLPb+H4kHPWTko\noW/rcP7s8mBbK9gRMfqY+iZFPaFSTwPd9ZGGOUj6fdqKxqgreV422hUywUVY\nezOhOzsAd+gKM2TN0W7eXIhHbHT8CMi+toXar5JfuqMjRvVy5FfvYybLsoku\nVt1u\r\n=P2So\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"31dff524529581f6d41765bff096b6e92b1628fe","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.26_1643305753588_0.9677608822231585","host":"s3://npm-registry-packages"}},"6.0.0-alpha.27":{"name":"streamr-client","version":"6.0.0-alpha.27","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.27","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"a6fb69ea9b153016ee3a44ee3b88c756a65c661d","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.27.tgz","fileCount":233,"integrity":"sha512-LGhkQRcyXNIFORBWxzNOEuXdTzmDHQcBacOHCqQuY8g0Eg+MRHvBSR1u4Ni0IwWocBF6WE+mX8wKMW5q2Y2QMA==","signatures":[{"sig":"MEYCIQCoW9OH80lqgEJv9MtpTrLoE4VSvO1uwf+T5o72/Uk3ogIhAMR14217kklff49Iky4ia08H/MLQ+ko58k47/71aV3by","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5567459,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh9+7YCRA9TVsSAnZWagAAGi4QAIaqWBiRh1r7Y6Fz9AQN\nUxG3BkAac3TpRTTZvzNXoYn6xVxXPDEvX3znzKTFGEwQgrpiclkK/oimz84z\ny8Cf0BgwoPnL6wmcLhzQVf4YIWSMcrWL/3UCG9zAA5kl06Iwy0+NUB1AOY6J\nBGo7RxAiTwlpE4zQ/J/BLiBS8Pb9dYWIolp0UgVyuMJFRVu6Hhkstve+omKD\n1HOJXnfuVmSCfSCtrTkzeSDOEhlW2mJ46LCTP5PchqSmLZMgkwszwyagUoas\nr9uKrOWukktT+RS+JXDV/HimN2yKdqnK3aW090auMFNsVeLyElVIfa8APlie\n4wGidft0Kc5Hus9G08dNjC5gvXFAESsHBHdnce+9Xv1RLyrQ+9w10yik5RYV\nJWbDg6iJtgtZ0vG1ajvwj5OTnsjBDLEz/xuh7uVN7HW75do1721XtpM4KOLW\nflKznuYGqRtvXNOuuFQyyA6sTz2bButcxEJ5oaSuuJTIw2W1sytUOC9XsxLR\nYOEh8zSefwG0AnQ30KgE4dPHXHEKY2OWjwgjyyKa5hOf7mU3ghRD6xBXpaMj\ntzCcdLTFDQ+Ijdg/hE9sdvySxu4jzc0m+ErZ7dK1+AWEN7jir48QQo2jZnec\nlIuuatIWFVG7eycp+Xo2drBnXJgHXduk4zGKYW58aNCExOrX1E8fJWsIekx7\nUph/\r\n=rviJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"d339adae48e1d0dd72212b386fdbcee23dc5e297","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.27_1643638487905_0.5889616476939834","host":"s3://npm-registry-packages"}},"6.0.0-alpha.28":{"name":"streamr-client","version":"6.0.0-alpha.28","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.28","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"969323a73269380effa61f3e4514b2fa1c218458","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.28.tgz","fileCount":247,"integrity":"sha512-+5idQeCx8C+3gnuqjDmn8wvfsp30ejxyuK6GjatzYw4cZnydHMGI7My1Eydxhbs9WYZ8KJfofMMYtF/Fv9WIzQ==","signatures":[{"sig":"MEYCIQDVLv7p86YcGlpY82TS3HX92yu8IgP4FvXgPNtrm8LWVwIhAO4AQzvF6VXfhVrYNOEbUfC5t+3Eds2nDOIYTExNA+Vt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5825318,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+TBbCRA9TVsSAnZWagAAQRwP/1VD9mZG3v/0hScLi+YB\nnHEUeoUaw4Ig4lzwhjeDelZ0pPJQzL3u5khvk4Do0ivu2ytNkrVc7kTwUcVY\nSQqqSPu4H97S4Bd7fXPdObNpRdGLjY7jRPeRnXPH6CCMnzp9hvdYjvgAvcRx\ncAzXLAb+dOOvZi3qIPEc3+C/b9jJwhBp9j5X5snBPZ5deW1GBgyL3NZyYgRi\nzCx8PeJ4xFQyP2yYq5P9nv2Fy8yf+Vl3sAiyHVgTp9Q8V9BGn2OMdAIgP4OD\nJX7EPyAsT25yI8yarRDctp3oL5D+IrV/Z39zAfhJmp+39SXI1r6yp/6foxv8\nrY5xtmhEHvTYHxLJ0p9djVZZDK4z3h6AccOOvBGGsbsEefAD3VlyYM0bLeDl\nZwBSAIXG5FeLAam/oNypl+SCbX7xV/xoH45uFUmbZUEcOZoUEM2EXJ+ADaYp\n9oOdZhV1hJdC1hXGtOlvtWpQZQe/NjLehpcbll58MhNB/sVk/sIZiN+2YYf5\nQEVix0/0yNAdjQIrBujAZ4tH4wPU9SjPm4SNvxfFgVF5IqinuglHqoFBBMtL\njzNDuClstm7cZCX4tnzSC3oIIJxMZlWyNSoYrN+qybXDA5lxXhbJHEtrnuR+\ncLUKkyPWqIgy4h2U1zWLho2CRIpoGAYuqELr/Dq3YB2vd0IhUYg0TSynqYBk\n+qgV\r\n=NvYx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"509ffd81ba302c245f51d74a5ac1d9c469ca9976","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.28_1643720795197_0.5804019510158445","host":"s3://npm-registry-packages"}},"6.0.0-alpha.29":{"name":"streamr-client","version":"6.0.0-alpha.29","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.29","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"7303129fa493af95f13d44dcc1184173c8915fef","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.29.tgz","fileCount":255,"integrity":"sha512-NN2rzBprQiWJD/U23MvFv1DcczvbbuANl9ayZeruqRtoKvUxJPcx47x4vn3rgWocBrFwzyZlo7pbtzrbQf0/Tw==","signatures":[{"sig":"MEUCIFwYqQAHQMLnpDRe18g152fSWx7Unxm046r4fOV29f6fAiEA0obqvbr9QOrq6NFS3Itq84J9auPi58wvZCHv5Cx4K0w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22736569,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+mvMCRA9TVsSAnZWagAAr9EQAIOZq+HG4UjIsxeEBr0y\ntgt5hNnDRFN69NY/xnqiP8O3WBLi2TmUS6EZnQ3hj1oQSqV4gV5Wqruhj/be\nDzpOvrwfDhvDMkD7tBJhCNUBwYd50grESzKszRvyPRrr7zwEtxhx9Q2h0Io5\n+c78TAr2LeF2TLf2+Ew/Up7WHgTUNbyP6SvIYrF/7cfwz0Dp9VjcpaQhxQ8b\n247NXA/auUjsngXHD2GgpfGM2zpSY/BnAHFL1AJ8E124qJQIDGeX/HC+8yp6\n+rhyYOJjv8AvG7PK0tpsa694KamlQrnMxaSb3tDAzdIVvqBc5ZNs2qWG5gNN\nqGpRHNX4DXUo83uJ65QEW8C1pNzTp99gJavGaCTaQaeuwiar2WFQfD70bDTC\np91exMClPvavhrsEpfed63iWw0kAA7x1qSquqm6CvUK4y/IEHHyew80ouiOE\n4era4KYKEWt7gQ9PzjCeVBIeVUNFFUWsmTfRMT9paDeIyoVq9/VrxsmgXQB0\nInOiq8Klpr3co4+CEjrLtAlYHVVOEpIUhaMrLxjLQlyILhrfqEibQ5d8ruXE\ns/7bJGKf0kwNstNEv8+63mZRn5IQtUCV1VFTnDuHSr7aI4Gz9yujwnRMORIb\n0VYOyucB4QVnkS8PSfgQdGROQLn4m4BbyGwZragt5KmakKqYjo96xAAl1tUq\n7bHs\r\n=5QtJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"27cd5cb9505edd49f258f5b85f219aeaa165ca7b","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.29_1643801548435_0.7338052595425635","host":"s3://npm-registry-packages"}},"6.0.0-alpha.30":{"name":"streamr-client","version":"6.0.0-alpha.30","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.30","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"94c0dd7d593edcd69fcf0762cc3f01b99d9daaca","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.30.tgz","fileCount":252,"integrity":"sha512-ewMWoSXvQjRx9l2HNIj7Tkb5hwKgT82tFjpLfIQWA0YMpX9ZInRlyMqb9qDHYFkrlTn0rn1TMj4gnLf67gpaOA==","signatures":[{"sig":"MEUCIHrnhTm3lLVCBtklIiUR0doGIGm0OsqRV+xMPWJQGJR+AiEAzAIaqOtzdHZ2ERQ9PvmkK/onpphjk2sYQPp84YVY4x8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22596575,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+8t4CRA9TVsSAnZWagAAEBMP/jOFUsJRkKIrn5gQpVtU\nCE3sl6VKSuY8F+AC72qCZ7Bk9yjQcSrdfz7XSxLMBE+j/swEbq5ZRVdkXRhT\nSj0g2FQWjM5+iXj7jRAeXwL1+6MxvCq+URsklK48HKFJsKCgKWqNKevpzxnB\nzMFpo9ick+PQ2+B11qdRDFA6Fqf+HmlysIgySEZ0EdV3O4VuxFge500SSpnq\nqxkTGeDLBV+J8vWdL3HVlYIArekCHY77DfPXVaTAnvSdHB/pUOKFeZEnc+Am\nmxUR3aeam+AYxOmqovSCpZsapYgQaXwL77JLzO56jbManuU0IDm/LsdOqx68\nmY1t6pqAXLEgKCkcw2KckHbn7/6rJPOni0zsTXz6+LhBtWeMgDU9ZtQQZUYJ\n1RfHaRCGi8nwNkP1b7/lT9Vzm9f17Mp26cnN00q4kXW0rgdHVVNbCYOmBq/F\nvVxCgUaJRmyjOZQ5QdajQiGRVWWTdvKhKOh4ttEcxtVxTVTt8x10TyvIkbCp\n8wCsbIFU4bd+VetveT9OuvAnK5REeUaYWSFheq8rGjnT23WyAKOJVzoi7hvm\nUKTlP+1PFmBFK//PkZb+uz9awgX7LoEOrbPQ8oQ6PKAkvJ3jv0vRVb10FfIz\nC5aqfVkqM6zpIsIIrbm5aYuK0YegmFdpO7Of9HrL34Uy45g6JGBL/cJvAhaN\nel3a\r\n=JiCd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"748d571e05beac7617baad22498d3d4eb1e387d1","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^32.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^11.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.30_1643891576341_0.5523801441938212","host":"s3://npm-registry-packages"}},"6.0.0-alpha.31":{"name":"streamr-client","version":"6.0.0-alpha.31","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.31","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c8973888db0be21d0259558c4a7fbb82a96418d8","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.31.tgz","fileCount":255,"integrity":"sha512-ydfQxlYMBsTzMmSe9ifAHrdTFFIs4Zp1kExAZJra/7s04EtoWmHOWgODKqUQvnCkzDK9bcZv4SoJStPzRYO9mg==","signatures":[{"sig":"MEYCIQC3H4qJd0f6AUePDuQ0cCWLa+iiSvlkEdGsKuBXs3B4RgIhAKkNowE8C6m92z0Qh6r/gxo5mwJR2x18OdF3M+8DMff8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22604610,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh/R8WCRA9TVsSAnZWagAAlnUP/10mUNV77GkVkECKQ7at\njwAU/8Qi8p6uCEw7HF3W7I13oCjBaMp4g1nNe2mqARfwLqRF+LMbwt/4nbRm\niSG3OSLCHDUzcnEHttwYNwESPAHUaaK4iMNJw8/F47p0BhRcL7soSkgb2B9O\njnmbWruoasX8cvLh3hKyq1mPSt7scVpHs7xffbR83t2bM346PwBrCh1mpAbL\nDIQ0XigXxJWCzCxpLwGYfnhPQEsQie5fI4yJH4igZvT8fdKWjTdgr4PCx10Z\n/Ia6rildb7xS64kDCA0YTrJbqaAM9I8mhsE6N8BDXeu9lEEPYfDIAtDBj3Q2\n48wBZoHaB8cWHprqFmP8zfbZWVyMSDVugh4D88yMCx7fVV8iJjisvnj+Zt77\n6Ku+7FH+YSXJm1SoZUQSAo+dZNwFgcRGSwTt7rJp6Zk2ZtwYScTIJ8162MrG\n8tX9tPTPfTSUSqOySh0QYW+cEAIIl++6ZCmjWtQ1DpMmC7tSTs7jl2bxYBih\nQP5d70Ut5KgtDUoB9KI7KeKpYuNh0LL8RMigQ6N8iOLThsMtJveirPm0kd9w\nf+iUM1KMV1bWEouNhIQg+a4JKg0cvUnYIfhLSKel7bmabqNQ9i1oRT1Qg/Xl\nJRV2/vHcZ13QeunY3ug5ZwQ4wPfHxG5Z7BQwKVlWSqdLNsYMC7KuyJlBUTK0\nPm8N\r\n=RqiB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"94a1e744bfed9afe26df8bf46d7ba4e967f84492","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^33.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.31_1643978518533_0.49337027018379365","host":"s3://npm-registry-packages"}},"6.0.0-alpha.32":{"name":"streamr-client","version":"6.0.0-alpha.32","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.32","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"964c5c27be7e1024d3d577a91f86ea537556d4b4","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.32.tgz","fileCount":258,"integrity":"sha512-/OZnyRu6wpreDgKt/+bU9pgQ5ee2jVSaOhpsNqUQMlsNQbS/dvfXJF18hVV+GFMokzuwjwHRUgeMBXwaaPiiHg==","signatures":[{"sig":"MEYCIQDXU/WoJGz+xUX9IwUUb2ThYn4OOysflOmO8/0lfW45DgIhAKr1zKBSIlqA+wR7j0IpB1o02WwCLM7jPTWZg9kWr24m","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22627318,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiAP7CCRA9TVsSAnZWagAAPkYQAI0/HUAzMUd+hmmNagRR\ncmaPYwJ4u1bB+4fUsR0+diyjRCgDPrqhSNHNtTsBwBXYpYTNrceFFGB4WQ/B\nc3caWlzuIlGwbUV92BPmuuBj02y4F7UgNoMaoc/DNR6icgy0eMYOErQG5B6x\ne/ONt53gWUfJnbhCRUab1mKFWcuhlfT7V91WKCjhsjLC6SY6sEXQNV8a+YOa\nWU7tDyeV2iDGsl16n7Eg940Qy4dg3Q4RLJD7KFOJfodk6XVCAuVSCIrp2jxv\nrkn0hhdSzyuVBzPJGoljsT2R72818Vn209li4W5NxQW3krZWxNxRpKTaSwxg\nOGDDBfB6ZkhVN940pO8tTY3tSPojCnZ5FD+rLMef8C6Uej92JU8x+tAak9C1\nostJbgkkaXmDgJpUCDAG/W1QbFuQsRju+lbMzj8vufIpxQYZmsk6R852Uznu\nQVh6mICZHlghvVc959vGgzzF86DGw9tBdo9Wlzh9QTrd/thu8GFE+IMUJdx5\nyaaJ9IqHNcvttIbnvY83zEWPl9C0qPQR/sKM0xols/YqqSl1IhujhS1cwUmR\nSKhmioBPBxRQJv7xCUbtRTWFRKnYIKIJsIWBNG+YEULoa6j1YCzlaVX/AyVL\nXziZ4Abm0XuxuwtRyEuBPOWli2wwXMpAtKAz3pUCtjTmqDJRMS+WVDYwH5OT\n2i9u\r\n=wZEw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"7e2ec1ded3b649416750ec8f6c9ff554bf818e3d","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^33.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.32_1644232386133_0.16254755689993572","host":"s3://npm-registry-packages"}},"6.0.0-alpha.33":{"name":"streamr-client","version":"6.0.0-alpha.33","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-alpha.33","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"db192366ca99c6d681fa1577b742c3bdd50c15e5","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-alpha.33.tgz","fileCount":258,"integrity":"sha512-R6vvKDPhFZTK3lQvuIo9c/F4Q0Rxhox4FPcFpraD1ysg8q6+zKqguC0npunMEiOHsikGPznJ4Rs8KABEItH3qw==","signatures":[{"sig":"MEUCIGY8XlTirfOv0XNjsYgB1hI7HfGlAftN1kBtw/CAga5WAiEA8zRszHRUVglS6Zn5Mdy4cdE0/FXoYuSyDNgGqXtrBhQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22620213,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiAQedCRA9TVsSAnZWagAAB1EP/3cKSCMvmYrJ+bjRcDKb\nCVLjLiDKZJC0yZEg06/ZtGL/jObmJY/U05Jj56EbVlXK66cnxk3Si7RrmFwN\n/IJTY6JVah7Hm5r+gJruBIieFnNOvpv09I+9kqasrTCbGpuP1mrmcBoSecjl\nhx1v34tk1Da3rLMQzoQwWv8qhM3zttTIVc6QwOJVnlC75Q6V2Gxf2UzlDT5e\nocqzwE3YZQ3yJ7OeZR2LMWMlvLMR3MLlTHXrYa27jyrg/qWbZ53uc1D1DKJr\nv8MBKXyGmkBL5pGW7AZFyYKmK4W8GDzWjAxheI+MAhd/GAPDknXMOEyUH0h7\ng9vR61btvR+6h57+PZDq8t+uZLo5KdtUuWQS2kl7XGo6qHtQQNaL/oYYxxO8\n0iDlAYu4GT2CQo8rWAuj9NUJIiog8EYaj7qOWWWlOauMWEAWHJtrflEnTT9m\nwWA2dcKqt4ZBfKcXT+t0KlN382UopVYrToSCpfLRIhc+4PYVad86FkyuHWTG\n25mjcMP5+mQZQa08ldoKJpIGsEvmuZVwvCMLsy1R1N9OQyCaFXFQC48PiOwX\nGcQswUpyxbyzRc1YkkoRXKmtcw+bh376jsmy+ib55lkb3RvM/CBDVV2TFnXI\nHR1zU91im3SWUm4pPn3WuiQMdnB8u34tgYVuantjJcGD5Ld5vFIYMys8w9MP\nIBof\r\n=uduB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"e47d3d5c791450809fef1aa24cebe78cd71121fa","_npmUser":{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.1.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^33.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-alpha.33_1644234653104_0.9038094904284966","host":"s3://npm-registry-packages"}},"6.0.0-beta.1":{"name":"streamr-client","version":"6.0.0-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-beta.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"8c26d0e20d50a34f7b1935073eac67595c266e71","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-beta.1.tgz","fileCount":258,"integrity":"sha512-OtQcrrcKRaMEZXkJkt5B4Emng9+HD2tvBx+UgJW8LH9N3gNNv6VjCtq3NRMr5oG6MuuVGpSiLc89hPID+4fiJw==","signatures":[{"sig":"MEQCIDm6Q1sgeO1t1xtEDvli+KXOHzRu9E7IjPYU0rRNVWrHAiApbHjxBSFB7m3rDKkPekSFwVTYxlGbTMvpeRnQwQul5Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22620886,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiASicCRA9TVsSAnZWagAAOnQQAIG6SRDVEtsy71dQqIx9\n+M/Cj8kP8f0X1XQWALQoDm9bGQqriYGHlDf0REwsNnZ7OVBW4REW1ioHqRMm\nAH8EBg19jcgh1c52xkGV+J2PhJwcfolWaa4GywDVVd+9mo4/O2AJAN7AiHF3\n1mu4Ekn4Y9cegElpyHlgjj6+0c8Rr6hGPs+ZCi8f/TkJz/2Ew/5K3sMvtDbj\nK8mQmSLWlFdDFP4e9KjfB/t/12RoeXVwZbqXWr1u9VW1mqwSBKLTVqqtf3Jo\nUdSSe7blZw3NvfCgvrIRjjfpJZUY7n6gaywtxhPgqsWKoiVfJbGV5ZiJ/Nof\ndPpck3IIBjqXTzuoSR4V5mlwXJE0m84GWZF6zG7RGHrNS/TyfihQRqRBwR7p\n3+45pkFtZQ0R2Nv+Vr/NSs+MYvYK4E9n1h4x/P55EY+vBEHgSJdidwlsWwCq\nwjRMI/6c2RhRzWnMqUkespZOsusj9+GOd+NOZCB5NMNKmWAFyFCS4azccD84\nwzqGj+IRhhOQfyJa+m1CtNQhNXpxVFPl6I9JtRILICeE90LE+XLjLVa+xnlS\nOmXqRp1TFZfEjfir4Avu6kdi1iEGpTFPQSPkV/zmdlgJI0C9bZEX9x7i3OIL\n//dNRBba7rxo8db0uxAg2WcVgvXPjU+7QslDqgyykSAFqvO97j1YFaH13eY2\nrHYU\r\n=7Jso\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"d1c543d272d3c7e4db20e94562769f41adb4db10","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^33.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^96.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-beta.1_1644243100428_0.8144518383487773","host":"s3://npm-registry-packages"}},"6.0.0-beta.2":{"name":"streamr-client","version":"6.0.0-beta.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-beta.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"5a5767820feeaa6032a3ba80fc51ae885f68b724","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-beta.2.tgz","fileCount":258,"integrity":"sha512-F2Nl9YAsfT/D8bUjaDaOYlZRIi82rR6vB6RNK1njTz5ZekGOwmvHQJkU/yo1snQcmx5oguk5lqMcVCu14K2mBg==","signatures":[{"sig":"MEQCIH6hrHziBjClrdC2POdgg09YigEqvZTIhxWwmXATRaf9AiATqREAnsKSmO75Dr5C5qX4TZIlwK0d6zbgqCuMqMfVEQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22645849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiBRVNCRA9TVsSAnZWagAAaagP/RE6jkn7M58B9uwnJMQm\nJny4yXl6N9+ZZd/M+sT6sRGTII2fvJbODnSB+Frx/nOxzerc9y251fSt4vw8\ndI44AWSxCLd8lyMCIJXPo4dMtO9+mp9+jMBe+jEl2gMFJbfaD2JPO50DwCUm\niBs1xXLNBhg5XGX3QVUCYJlGokzcsw++op2UBBq0kwoBNBxBCa4CsJcL5WCi\nS060VVU1h8bSjilKOdv/OsvKK0d6l4J4FQvYWnjF+Qo6wFJ6jLSBHOXjVr9g\nAaOPka7Gf4ddNsAdWHLlSArGjcjF2La3dyocj7bM1PY6lUF8dllwhvclVl+i\nP5/cpo79dM9Z2JDWiMhlerfBU8ylqzGwUxtjX+vNHbJtQFUqrbXc2H7qY/YC\ntxFavnvo0Bt1YhsG4ZbgrLS7smdyV1odviWD8npi5wid0lb0EZpnKkPyDfiW\ns4mXDLYdfRiRHHA/cewqsNzGO6/BKK/NZ1Q0URFyok/6VqFodFMITQ4lCXrM\nhJRfHGb6RtMDiN5npAmfdMjnyIVPtnRhY0FqbQPLcQD1c0KMgBQE3mdNp7QQ\nZN4t+jmtD4vd/G4SgiFGWR2VEbXYlmegaaQBYob+m3bV8bpafOBtbn0/tBTB\nQS6Gn5ERGPQaqXFD1SS6WxsgVxlAGp8eJtkDJLhaYOO6d2wf9Q+hxYAnJfgH\nS6se\r\n=FUKN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| restUrl                  | <https://streamr.network/api/v2> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"0a3b4e46b89a4eb1a6ba2948b38074343cc30e3c","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.4.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^34.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-beta.2_1644500301203_0.11853488119990363","host":"s3://npm-registry-packages"}},"6.0.0-beta.3":{"name":"streamr-client","version":"6.0.0-beta.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-beta.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ed2cbf4f962dc81dbb5151fe8af1fc9e17200207","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-beta.3.tgz","fileCount":261,"integrity":"sha512-XEwtnay2pOUlpICrDW2kylpSGtwc67CrZa0crAvNiNH9Fp/+TSChB56PcvzSo3D8N3Yyq2oR+Sf5Ekgvd7cHIQ==","signatures":[{"sig":"MEUCIH9jeNylbusNN2Wl7qw+LukpQRFssbsPjx4sm0NCpqr3AiEA9KW1fWLcODgzQ9ne8WZV7AdUhhPRuKpylXEuaxBnN7c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22665774,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiDmOrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqx6g//fu3yMAZ531Tq/r2zANwKZ6XZVDkbUDekp6qsQxiHEEH1Uh6J\r\nNEKiY7wfzZNEE6RwVpBDNe6lgt3FjXwrGyMiEWFY1JkzmjdMDegTnBTK2R0v\r\nhiWrk9+hHaNbC4eybEAnFONr5bvvIZ8MlNGm6JJMHnszDyY3pCKj+i0vd+2q\r\nyY/ApOwRPvQm+jeNcmrFPx1bKyCka/G56rGXvIL1XguqQB5zeOe+WU7pEI0S\r\n+GsDGqw6dvfwV6FzFAsbcndVPF4hbZxLnkzNdp+8iY4dODNNl6Udizx7K8Cu\r\nZrVLvuAlchUiLRLIuwNZmM9+Ige0CJr42J6oTAMagV+lBDupcGEtRhfMpYM1\r\nvo5+44Fm1BQF3Xujw7Co+uQWsfIRDHNKBpu+eb/v49NtRy+R7ZcV5gkBzgzx\r\nYfAAGRkM+tgoS/Jr5uQLm70LBEIbIQSNlY0yyUef2JK+tJrCTBM8INvu74rD\r\nOqV2ye8sYyzmUYzs7F2EnxKdppxhmCtBGT219O2TIn+GT37RTs+b6QI2uV0G\r\nSqH/rEiZJhHF/xskL9gAjijViMq1hBJ4BFMG09FppFYrKChUl810T4/lGW8x\r\nM5cdGjzMlCKUnlON+HUY3RrOoEk761SML212WT1+xMMcMmCZPVcVyyo77rcj\r\nHVz/GAYpIEufxl1Hu0yqaqpAXlspJLbVclg=\r\n=sh4j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream permissions](#stream-permissions) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend(\n    'streamId',\n    {\n        last: 5,\n    }, \n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| restUrl                  | <https://streamr.network/api/v2> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          |                                                                                                                                                                                                                               |\n| hasPermissions()                          | |\n| grantPermissions(              )          | |\n| revokePermissions()                       | |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermissions()`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermissions()`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream permissions\n\nThere are 5 different permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\nTo grant and revoke permissions:\n\n```js\nawait stream.grantPermissions({ \n    user: '0x1234567890123456789012345678901234567890',  // or \"public: true\" to grant a public permission\n    permissions: [StreamPermission.PUBLISH, StreamPermission.EDIT]\n})\n\nawait stream.revokePermissions({ \n    user: '0x1234567890123456789012345678901234567890',  // or \"public: true\" to revoke a public permission\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\nThere is also a `client.setPermissions` method which is otherwise equal to `grantPermission()`, but if there are existing permissions for the same users in that stream, the previous permissions are overwritten:\n\n```js\nawait client.setPermissions(streamId, {\n    user: '0x1111111111111111111111111111111111111111',\n    permissions: [StreamPermission.EDIT]\n}, {\n    user: '0x2222222222222222222222222222222222222222',\n    permissions: [StreamPermission.GRANT]\n}, {\n    public: true,\n    permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user,\n    allowPublic: true\n}\n```\n\nTo query your own permissions:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: await client.getAddress(),\n    allowPublic: true\n}\n```\n\nAll streams permissions can be queried by calling `stream.getPermissions()`.\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"283c6e30148e346331515ed54564414861105def","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.4.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^34.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-beta.3_1645110187684_0.1136600115211095","host":"s3://npm-registry-packages"}},"6.0.0-beta.4":{"name":"streamr-client","version":"6.0.0-beta.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0-beta.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"6aa6837df5c62d7a27040b09ef2486216b98871c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0-beta.4.tgz","fileCount":261,"integrity":"sha512-eCsLID5RicN3TYqqaKw6vcS36i8QLOAPCJfkq+VCiS4yCxJY8n4kn7L2/LFPBsXbEdw5/ABgXvxXxqICDni44A==","signatures":[{"sig":"MEUCIE7kwqfuWYUfqORqIaR8mIi5ZwloCJCudFTbBb0KjE+yAiEAjVj4YY+243V4gW/Dp1RQkNNH7VK867zshRmxd0XOUKw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22668262,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiFRbNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrSrw/+Nh6C6WyjhnkLBJPc3J7eQlmI+U/bVmxbTTxb6SW1/7AyFEv9\r\nBPeXD/W/L2NaWyI744Fcd6KiClGh/xTstHT2bWCiyTqkbXs36TfWKZiW+bjy\r\nRyJVRH7xZ4RWe/3hiN6v+6uxj7Ev7W70Ovtfll4F4YCi+gVs8iRKbxSvs7Bc\r\nmJc+O4ByeLBX21dDKspEXVMwqBtM+LPN11n+IK5EQhcMqTZfkdNC+WjUHHjy\r\nPqx5yZn46cydFjzLgLrHmrG1zoV/dfI4QHmPGTl2pQlsWrl716KfHm4gQtlV\r\nQALmlOR0W+KFIf5Llz5eG14SeWJQz+K3tSKH2JWGmY0Wntv/eM5mxEOMt+I8\r\nQ+G29tFd9tI9TLiErvcMkwMRnvHo3/WKipaUMRL1zvc7PWDsAczE6O2AD9yp\r\nd+N0e+KEgLXo4KY9ESQPHphXbUFVqhOdxd/71mmLseynSzFsznDS3wvExfrA\r\nhvIGItN3h543b4Vf2e3FS5e72N06sIOJXYsONO1vN/8XQ80EVkv2SYs2qI01\r\nWeCrfIu4elizwjlAltgJ1l+TKFasqkiZPBQm0GeLioqPGej3CG2401OuccMU\r\nMRyg3RNY/w2V0pLYQqqJRg4LJjbX80tHBJ6CApvBiUUwhCSRBU84+nibJ1j7\r\n/2pQDjL+5f9d1bthX6Grkk/nZnPOJLmdRDs=\r\n=NoAu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to data, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Important information\n\nThe current stable version of the Streamr Client is `5.x` (at the time of writing, December 2021) which is connected to the [Corea Network](https://streamr.network/roadmap). The Brubeck Network Streamr Client is the [6.0.0-alpha.19](https://www.npmjs.com/package/streamr-client/v/6.0.0-alpha.19) build along with the `testnet` builds of the Broker node. The developer experience of the two networks is the same, however, the `6.0.0-alpha.19` client also runs as a light node in the network, whereas the `5.x` era client communicates remotely to a Streamr run node. When the Streamr Network transitions into the Brubeck era (ETA Jan/Feb 2022), data guarantees of `5.x` clients will need to be reassessed. Publishing data to the Brubeck network will only be visible in the [Brubeck Core UI](https://brubeck.streamr.network). The Marketplace, Core app and CLI tool are currently all configured to interact with the Corea Network only. Take care not to mix networks during this transition period.\n\n----\n\n## Table of contents\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Storage](#storage) ·[Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream permissions](#stream-permissions) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n## Usage\n\nHere are some usage examples. More examples can be found [here](https://github.com/streamr-dev/examples).\n\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-ethereum-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend(\n    'streamId',\n    {\n        last: 5,\n    }, \n    (message) => {\n        // This is the message handler which gets called for every received message in the stream.\n        // Do something with the message here!\n    }\n)\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nconst { StorageNode, StreamrClient } = require('streamr-client').StreamrClient\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| restUrl                  | <https://streamr.network/api/v2> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example,\n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n### Storage\n\nYou can enable data storage on your streams to retain historical data in one or more geographic locations of your choice. By default storage is not enabled on streams.\n\n`await stream.addToStorageNode(StorageNode.STREAMR_GERMANY)`\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| searchStreams(term)                                 | Fetches an array of stream objects      |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          |                                                                                                                                                                                                                               |\n| hasPermissions()                          | |\n| grantPermissions(              )          | |\n| revokePermissions()                       | |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [TypeScript generated function documentation](https://streamr-dev.github.io/streamr-client-javascript/classes/dataunion_dataunion.dataunion.html) for information on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermissions()`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermissions()`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction)       | Transaction receipt | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {status, totalEarnings, withdrawableEarnings}  | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient()\nconst dataUnion = await client.getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    |\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream permissions\n\nThere are 5 different permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\nTo grant and revoke permissions:\n\n```js\nawait stream.grantPermissions({ \n    user: '0x1234567890123456789012345678901234567890',  // or \"public: true\" to grant a public permission\n    permissions: [StreamPermission.PUBLISH, StreamPermission.EDIT]\n})\n\nawait stream.revokePermissions({ \n    user: '0x1234567890123456789012345678901234567890',  // or \"public: true\" to revoke a public permission\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\nThere is also method `client.setPermissions`. You can use it to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten:\n\n```js\nawait client.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x1111111111111111111111111111111111111111',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x2222222222222222222222222222222222222222',\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user,\n    allowPublic: true\n}\n```\n\nTo query your own permissions:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: await client.getAddress(),\n    allowPublic: true\n}\n```\n\nAll streams permissions can be queried by calling `stream.getPermissions()`.\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Proxy publishing\n\nIn some cases the client might be interested in publishing data without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, 'proxyNodeId')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, proxyNodeId1)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['proxyNodeId1', 'proxyNodeId2'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"f15067ca9b7fadb999efae781c59877a8e35c919","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.4.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0-beta.4_1645549261098_0.32480432778174384","host":"s3://npm-registry-packages"}},"6.0.0":{"name":"streamr-client","version":"6.0.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.0","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"08e2ca9c2b405b13441f69e57790936923d31a09","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.0.tgz","fileCount":261,"integrity":"sha512-iVc5ld6ruQDRLkyDwnvqmjohc2AQ0Zh7sxhsqiB6UkRTh+nZAGGCTHVP01gBt20A5NrLbWIst0eyhrtP20p1Xg==","signatures":[{"sig":"MEUCIQC7LKqj6MVf1c0ScjMertQc1WrePuh1oOVss8Fdw5iIlwIgFydQj0Zi46wp5F2RJlRs/K32gZFetF1/3G8syn5EiMY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22648470,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiFoREACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq/Pg/+MpMVPS0OYmxtD/vc1mvk7RtVdt8Znt4HuGumlI5/j2nMDu2+\r\ndklcNjQBDNyLdI39CYoCRlenEqmpRYsBHKUjiBT+dSKEQIktqC1AT6h3/ODB\r\nXS9zEQrHQYIrnE6FDwZmsjPH6o3VvRuB5+rDRpSo+44JM3ESD1xP7kCjrzUf\r\nE7K5WbStsyg6RJNxn6qKdJcwbobOGV8unrQuktZmFiaxkVVoMKfhmAmVQxLW\r\nNtawV0P5WIgQc2LeCfUEeL+Cvs0LBvZvkgL5sMxFoM9N4ACAxjPXp9JwldyC\r\nY39WoZytOgTgfyogMh6Qq1hVvl3rqFkCzc3rqeGrjtwMnEVk8Duo5dsyfBTr\r\nEwHPmY4+5fFlX6FJv0XYkkfdK4/Ysk21RLnKUA5mrlk2tGd1U218RKEshv8W\r\nr2HHtjk+u3KLblppXYgrhZVW8BSmEvTdFEPWfxznR+RxXupVqdR2iVZBPOBg\r\nQIHQ9hENeCpdAlI3n3/8/xsi4VKv0Bq5WXlNJTurZz3F5SnAOivEns1iZ8+L\r\n5SGua9cPby6lSNdokjF360vMQhVJ88IfKlepmSouYeP4QoDi8ed8sgzHfUd8\r\nD+b4v1wAJAIq5tG+5XnuEh05IN8/sxhWGyZ2liOONuNvl1tDW9qoFmVYTCD8\r\n89ZKQKKS/dkigJfDeGJJ7VedStxch68H8HE=\r\n=XKSY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"a6196aefd38338e41c44c356adaf7759f876633c","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.4.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.0_1645642819955_0.35851796751445786","host":"s3://npm-registry-packages"}},"6.0.1":{"name":"streamr-client","version":"6.0.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"f05e18a604471d3ec512365d4e5cf7184ba41bbc","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.1.tgz","fileCount":261,"integrity":"sha512-fnmxCDvpAUhBhYEscySYgdGRmYqC82/zoE6IugotwkB+tuLE4OmZENa3qKCYMeUZBOn+jsf4zR9uBviLt7E2WA==","signatures":[{"sig":"MEQCID9/EiPpa1NGAdoYSL4C9NgudoAJp2sBbE6ASkyYjFN3AiArD03G6bgX7hfPNdyahvHZwZK9/Os3cRyQepzHPAk/jQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22642586,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiF8XAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq0Wg//ZKBl9FITGV4KwgCMtvs9H3mKEeEhBB9+52xKaq1mdR7UmObl\r\nTdgT4ODmwKbxIlUGcT7b9G1D4bu+7P+eJa6qb2ZC+r32efgug0EgL3KvhbSF\r\nMUuPavV1Fwcp7Zthqdt2plCPTQ3rv8X7JdVKGBMc+1M0L8EC9M+SIUmGPfAz\r\nO0paYDpXFITtYr66XAegguDZzHr2A3nIimy8bw3em+4zaSoOvUJkSlC8eItL\r\nMngoLQK/qk7y8fIhupEzuKWSkKI3Us5bT7n2DOicbQA+i/+UDwaQaFRkT0FK\r\nQcZKai52z92rVjQzbAhGyKZhjs1owHMEhxiIz/x3xAB2QgtJhiT5tK5nhFS9\r\nHO8ZhbghA6TEUt3m8QMxq8KxAPRomIlTeyahPmpJFdBRDl1AA/M5KBk0QAMd\r\nJ5uqRNInGBiBHfaRBHtxTN1s8DPoatbeqs4i2Ylef/ROnjbM+kIfWIjPdUOF\r\n2+HRIx6NEwUmHx+cr/916C5217vL7cfyWLg+Z9dNvvjwO5OD83noyfCWnN4m\r\nYaRAFrm+sM3fofQuFmA7dUYbugGJtgfnUXUUN4supvqwAk7LJ+oWfzUayzkl\r\n0n0nW+eMQaH2CaV3EnK7bRo+ruBUiUeitsn048zfApiXe3IYg0BLdOUMJPdq\r\n6QoiwROlUAxghdaF9hYIMbmpdsvJCkZXEzw=\r\n=GHee\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"e7339105b34af172829510a8fd7c814d6f26e002","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.4.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.1_1645725120377_0.9761049765223964","host":"s3://npm-registry-packages"}},"6.0.2":{"name":"streamr-client","version":"6.0.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"68ec1bc582ac49cf59b3a3978be35f73a2bae50f","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.2.tgz","fileCount":261,"integrity":"sha512-7jOB2elgedv0LLq6vrXQzdFilzgvHgaZU7KSwItJ3l69GKPuzTXtJ4hj62fBCBAgWp6bQBpZnaQzkOZAWCvEcQ==","signatures":[{"sig":"MEUCIQD7y5iI3TZ0yO+zW4gvfeV0hMHIy3UJrL2jzhD+8ISTPAIgVgA1xtilqQvANGFHBw7BKeV9mDvEJjKxelPcrpA/gjk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22665857,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiIgmvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrjhA//cshLdESUeT03nCKEltAcHj65ToHP+z6pLLzNUaWo7gATKw0L\r\nK9UIz2huvwkwvs5aWkEVpXzkOhjvzFrHaHI6u8Uei5OWdYfQ84e9KkDkuy7c\r\nxThRwA/nOpuB//fqB7HbPOM+bB5M3QXBg0yx++BDwwgOYXwDnrMAua2Km2Ym\r\nGSvEfXj2X1L0WHrmgvLK28TXx03owd6rmrYWE6+th2kofeCLZ2RqmnRN0lxZ\r\nEI2B7K6PiQOh1ZdFokTzfbJnEq8gVdfy7jGThESEw79uLwkG+de5Gv3vJ6Q6\r\nH+SMnBuQDQ6WTDQcryHPXGq+j7duIoQGxhcTKHEVv7cXE5AO4qAvRo5zh8aP\r\nryYtsFEi23svCWBO0+dmHHhBB+Lwvo1jcZzVAjTeh0lNpj5Q22CQf4Da82D4\r\nbm8ywaB2Agf0JwD1JuimyWyj6YD+vZj6l+Je5B+qQD5dE/05DNFcEzjBmHv9\r\n9PE0U8NATOcq68NjUKRfZ1/mGKfpv/inkAJfwgFFqI5nF1LQd1TxD+QBs7Mi\r\nnK64dR2tEJXwKcERnR0yXZUSxVvBPiF1FZq8b3lHb72NPTquHDZ46rtd/Bsb\r\nGHKiuknxpHwo3urgQlnnoXeXwsomoHCUe4qmRG+nOgYF0yON6iSiJ0rbV78p\r\nzSENiNsUhjIxvvVUaQeeBIbEOZmJQXGU3sg=\r\n=+hsS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"60f8c20b18c62f2e1bac77617823a4458629500e","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.3.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.10.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.2_1646397871481_0.9703243663103962","host":"s3://npm-registry-packages"}},"6.0.3":{"name":"streamr-client","version":"6.0.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"9eb923c619802b724da15dddd1feaa71545354b3","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.3.tgz","fileCount":261,"integrity":"sha512-m+qGWLzYEmSt/nNNXXHf+EGrcbcL9bf1jlmfyMgEhwIf8TlzHibUBEa5NVaEMnpAgmgvB3gty5N9EcZzMYLTOw==","signatures":[{"sig":"MEUCIB/JuVobBwG4KzQkQNyfsSLGVaRzB6OkVfrSw9RrH6TaAiEAzPe+d6WoA0wMDtSLIYs4t5/uv6jlWdO3YzPwvjxl8Io=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22667105,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiZpp1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr1/Q//dlzLNATnySRSM+TfdNN31oKXjT+Bph3Xd7ybiQ7mBqyrGaOo\r\njNsna4hUVomIBhvZyIhg/0IhTusgr1aGaWlebCqhR5yPSz00PrD4bOVbZzPz\r\n806L+KAp0TYXMzXybWg0G2AYeo//GBiZTrS4qIuG1Yf8F4FCCUFjhhjnzv/t\r\nfPqifGhmjvE+i8Owm2GaMhxPi3KtkfqBMbHjGTxPmlYLFwfvuWmxIq5IxPDn\r\nMYUfi2eQdOi7HazVeH9/brBLHxxxgTZj56W1c/wq1wTSfeMbWNHHpxFBWV7j\r\ns9sr7FAd8okFZXyiWgIqHqfao+xrK7xEvfRgN5NDYIPhfFsI38iUQ7Q+YE2D\r\nw3U8a2gvPHyukGqWY3ruTG/712Qr7Dsjgt7JzQPf9Qj2uGV95L30WWLyieTi\r\nqGgy1d1zB1kkwy4bbY7OolWELwEv8wzyW85CDRVVh5b6N6/UoD8y338IzRYV\r\n4EsynNKi7mh5FDhf9k3krfXMvHQK8pnjsLix/IK04wU/iplYPHfBTCz6dT1t\r\nXUMZVz3+vnKmBCrmYkeka2n3QQOIorF0tF4MDkZxKvpN75ffJ2bqCcGJ2MHT\r\noGBQWT8o6Hpvg32/zVwMscF3lG+JjXlsmALhSFsUDSzKqXihSsS8BMwbbsv7\r\nzkYFJlvT3m8MytZ0jZiLa6e3qyUaQ2+OBoM=\r\n=Tkz5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"c5b81e916689f4ae5511df0be9c0bfd59082100e","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.5.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.3_1650891381075_0.17278577483838098","host":"s3://npm-registry-packages"}},"6.0.4":{"name":"streamr-client","version":"6.0.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"juhah","email":"juha.haavisto@streamr.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"jwolff","email":"jwolff@isentropy.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"},{"name":"simppafi","email":"simo.santavirta@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"829541a0c14f8e6a6971767996540969ac0f1963","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.4.tgz","fileCount":261,"integrity":"sha512-TJAOBwI+RlkkkKkpwRXalIpUt4l2uzlpElOLC2v10dqYm/fLaK8MJ/XVEGbA8Kdwe/bfWT/sOuh25XwOsYOlGg==","signatures":[{"sig":"MEUCIC7vGBcL0afAdD1gUsficgRGBGhMwl8BhecPeE7xDGLIAiEAmPyD7CdWCJXAvKcqzXcDQUsigDtS9vJ90xS3qeOiGG8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22645169,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaoe/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoumQ//TinEvc8iU5/sgOPBfKvPDN3SxoQxCmfXVr9O5cX1Cx6s0C+G\r\nJOD9woS/g9sHn+vmoc5ibUCaSn9NsgmzT1SnSSBaq6OVYH6+K61ps0H06LTK\r\nErut0a8MMnT2X0+DVSRxPHeh0NRnvmqBKMb4z97m5Y03vGf8sKgCEd4mshqL\r\nNsWBy/HyNGhLlRbTb1Rsh4r0Vfx4sbgFKu+EFb+ClUghgswRmN6UjnCMz7Au\r\nqkCZZdHJeqgfHxqH+vD+48m41hXCQnN71VexsTDwvm0indDv29A1+cJQVim3\r\n0VVwJEcKBKffLFiIMKCRvl8n5pQb0Us+8m3ikNMEzWbk9b4PhXNS8Hcy7LxF\r\nDI9DbCA19txmmE01zpmY7zScTofKjhyK/hNIitxKJigYtF5dt0Xk4bwtYg0r\r\nvzuhPka7k4rzL5QH/5ebtJ+a8NE1tvthdvr+tWmji6y0QMoVMqUZRbZLNDoF\r\nRssInYG0Ef/WFhnsf+8K2zdV+wXmEN0UOJ/ueOlRQJeCT3utTpt0xrjpyMVS\r\nB5dd6rUpt4LgxuR5CU8rGoekDsuiu5e9J1ZgIZhgKha6BNG/bLDVRdbbQxBZ\r\nnI4Bo24dXplSLDDqYGZxzznlGQ0+2W+lQvygGptzor2HgnA1HCO+ErtsxQ6b\r\n+EPPPtt3zVv48ILII4JM/EWhJDyxlCrLnCc=\r\n=7Z3W\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"d22b4774e4e5003e482241297e13626baa521703","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.1","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.4_1651148735226_0.9085512389355965","host":"s3://npm-registry-packages"}},"6.0.5":{"name":"streamr-client","version":"6.0.5","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.5","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ab7083d412b90aefdc6b1ab805bde610b2b329c4","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.5.tgz","fileCount":261,"integrity":"sha512-3dokrPl3fixWEdnRRzhHaZs3a1VyQL1uRGCW20wpVq7DltxoWBJrKi2YxYnvf10wX9iZbi692nNlJDoAmSuu1Q==","signatures":[{"sig":"MEYCIQDMF1v5mHNOOF2R028N7uV3UsFs0ZvX7uMOzCYKc1HbzgIhAKlUbi4Uj7VcRf3MuGhCsfMK9izivr/uYMu69OMHhBKD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22646309,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiehNnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqXZhAAhrp84pm6zEJoCwBPsLmOWlaFklICEGgJvNbfuibHqTW90SYV\r\nLBe4oe49kC5BxYbb6fzPyD+fe/HQuxtvvU7mcueJiEiCuja+Vmg7xhiLT0Ui\r\nK0/Cjbtb/ro0hrrqweayocpvwPS79e6jY7W2SMC/ODDHoBr2vFYM5wkjFM2V\r\nrGuIX2LkOiDRtQQ1sStM9TalHwP3+oTyG3kKFYCoZ2LZ5ITTiLcQ2E0WnrCw\r\nYKx8/p1/bVHPfX/C15VHZiLOqjznlSCuAmOfU2ruAN5VvXGtn6WauFiezeQU\r\nNZ9B562IWRBFivQ4J/5NRNV2bIPIhJ5aY8AK5p/h0HJ7NZVw5h01PLupZ0bd\r\nuZd24xjtmJ21tlCO3QyexgvqqaY+HZ/U+LKqVqe3UeX6Q5aD8I7XrDT53QvD\r\nNJ/wex5+xOTUwSffacIJ0FHfwa0GV68z2q3SXw4+TuDIlFHJ7iIHMco6mooj\r\nzhKgOsdnV7P9GH3OqfY7fKDjdPwjLx3UzPy2uqpO+GHijLzcEq61xxYHY9Od\r\nJU+bk4U4b1HsXk2cKI+Gs3Q/3XkYZKMs37ZM5DGo70GbyoTTVj/5q2EH5spS\r\nmglfb16saQ7rIFrShlcd+RoUGRIrQQ5QCUofagzajeCB7q+hPYYPE1dXTWjU\r\nVrMFFOglT54+Uo6nl4o3z99EFJjwwpiC278=\r\n=v9Vr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"58c5c998bc1c062e0fb82d3c7b5d5593200eb1fc","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.5_1652167527335_0.06147940384459183","host":"s3://npm-registry-packages"}},"6.0.6":{"name":"streamr-client","version":"6.0.6","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.6","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"009d9d1252d56d20f1ddf2dc06a1b3804c904d96","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.6.tgz","fileCount":261,"integrity":"sha512-hHgJQFB5tuEORnCdvWdt/h0Di3JkbUbbXsdXbxvUEr6rWAosZhasJNL8bMomGNCS/HeA8szwC8wc36U3A6Ozjw==","signatures":[{"sig":"MEYCIQCkOsuRSzNZl/gS/E614l8faKTjHZiOFFo6/LMsr6lZYwIhAOo4FqMsGaH6ydjyz0ClEoHPxsSlpc4cXI613+aIY5hv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22646991,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJijMgaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqubw/8DXn4AbP1hOOMJ0YEqldBRquTqHFuW1L5IwDauG4HNDw68iRn\r\nz+A7QovSeDca/5oHsJEnnE9VUy3kjEPjJiNzwBt96oDGtwv+iCaEX8Gg1FDs\r\n9o5WTl4k7bXH+QA7HPHzZvmBapKW/ov9Z6uo/keiLhN4dZcSgyiNTY0WaGJZ\r\n61vvmBmfhnb0Dgr3ANylahFGZI020PCKmGoemWECOjrsFWYQLyN7VE01XP0u\r\n7SwqXjI/tEYy0ngv7f8S2hejYCMDFsHJx0solDCZ+fbSOXZkXvRPnbVzD1v3\r\nGr6DsCzJN7GD1hFIawy78haDhuxFSN4BZjsfOJn3ADmcJuwh9/gphcJgP/Ov\r\nUi+cx9mYqXjt8yuAxz+CPGTDmDng4bPp7xnF/Bt+nqG6sr58Amdf2vw4ZQOX\r\nYZJSUQKgzYKdWENjFykqfzDc4OvGmYph4SsH0EnMH7vfANImJBzEwf/ADl6f\r\nPOAfsJ9ELV7JlOaL579WN4wNPDZxmnHAG/mUTg8waKN+WO6ExVyyyYuMtCzB\r\n9oAYfDYRzwS2WvusBrKTfXU5S7Yl/IYhXJBXpZlrTsqbaFbKmJZpXhzynfvP\r\nevpr3pCWzga/xwEXkzQW+J9gdSF0MhjzNaQLKmqIPW7zbt573rO0lgeuUR+n\r\nppyyqTyL0HkhocXicBWwFYchPZRw5PklLiE=\r\n=uFeH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"77f6d03ebd6f695d597b5b2bf5719593a72cb1c5","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.2","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.6_1653393433755_0.8547281185796161","host":"s3://npm-registry-packages"}},"6.0.7":{"name":"streamr-client","version":"6.0.7","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.7","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"bd74f7119837e90306eaf44151e6828ed0a75240","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.7.tgz","fileCount":261,"integrity":"sha512-30WxvitKlofMfYKTQ62oglpBOy/KS+mSos0WDBWVM40db2QMyrA0Qg0N809QYYkeOAOKJAv7Qg0qkXsll7LLrQ==","signatures":[{"sig":"MEQCIFZ07wZBXMtPPzYsbnXDdD1WigJYHoI3v0g+eS8lDf4aAiBIUgETnHa3748EnyJ+XT0tnHU4wkopD33UDitz+nInJw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22647392,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiji1EACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpDCQ/7BhwyZI9ke4p2/yrkEscxfmFwO7q5c45Tjkl9nvtn3VDzJ1EF\r\ncVkRZFElZxZW4nmICo2i14ZYJKPJMaivOicXba8EwD2YHs5u6br+R5lOQmDk\r\nZ3/SzcMoiiV7w4f4+/pDh5sutNAG+U8OdNEjHdgC1SUW37QYwSheyhQvso6o\r\n0TlULPZjG9PLgvvGUsN6EdGOd1X3i3IjJUhOQan6jqwOP7Ogk3I3jnB6COcI\r\nhWUfGPtR+croWwU2OdmTqPe+lvBTk+3rZ0eL2lQQXer0piAWJuiNk+t3pnmN\r\ne9oP9Dx13usebNU9vUc0NqEbRPM735IwTW8sR60Upe3mjIFVjCl3kg3kN99N\r\nDPSWCPvKR2MYTZ11cO7xJP4gFRKCcRXsoEcPEklA7iYzkcYxHrerB+6jw+6L\r\nfG8p7yt0LFsiRMPAK2I2W8oPKyxSzIRjT5TNoO/JpqXlbFkVOK5CqvmGayJC\r\n6ASVgA0H7fP8pDorcDLVqzPHLoJIZ7eAH/xdmH2psZrdLCos9g9Z23LB4BYe\r\nrwTed4BL3NzTT8EHWeiKi75gbTaQW1qZjbTAfonSGuwEcV6RODJDMvnttxMF\r\n9TgAQqIjOom8wXMrtrIwRfzLB5hFiHgGOD0UkVHfexYjTrS1r1lDH/UYhi2Z\r\nrHyHEUBTozhGfonykvr/aIi+l5fSEj2CeUQ=\r\n=5Rjy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"367e3cfedceb9b3928ea26924e8711e5571cae23","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.3","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.7_1653484868660_0.9093509374338795","host":"s3://npm-registry-packages"}},"6.0.8":{"name":"streamr-client","version":"6.0.8","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.8","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"1f78780f840910d335d28d363d04260fd35c0c98","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.8.tgz","fileCount":261,"integrity":"sha512-BfxpGWC4cnGWTfw+EAiiuZuirbQEbpEIx+izNCDAIWuk0dwTPzlX6OATCtlYBD3b8U8os/G7sXw0mVqrVwxMng==","signatures":[{"sig":"MEUCIELOFxDhirtRT7uyFXixeg/osbYR/KItpUSWvl+m2BzuAiEA1VG0rdwGXLEKiBnwNc0VtyscAb+EWvzCUPsSAfMcsvo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22654779,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJildv3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpxKRAAgnh0D3jZfXEudErxe6JcqsFaW+zMJu7++wTdzBN4X9kTy1hE\r\n1mBhr/XtcxEucMzYM8lu+OxvzoQZh6Ozi1/UX1oz7J0kq5WukRJbiGx1yBks\r\nbCxe2NU98smLyOTeeXBFQh5ri0ccpRoGvrFWyw76rp+Pa9K6rdlBqGH5ERcv\r\nhfsSWxHPQXKeHZIv4YPOgd12sfih3gmaYyfEdpwPuDEas8JBfQcjuYaXKZ5j\r\nUOOcrqte/L9eqLOIVNAFPDxaOC15gPLzL6xJ1C6wt3Ii7QNeIQ7b4GVCyWbZ\r\n1UKRlGzfbR3IUdWap9VOtgRQhKhBdmi5yf+WIR0cpRGSCh5YFCTgTnTiWBsS\r\nOW2dObROfvdkYiT2XcMWLAtDtZaMrrysotkFJq07A0L9i62sUPtq34ExLNZ1\r\nu8EN+c8xG848TyRfYHwqOxtHg/hT6awpuqVuxXdhx7MqONXl3wdLoGES7kaV\r\nUDCP6DLW85NkF4TRbW4T5Ph2umINMReQnRqIM39nWvJURcS2z22/FTQhrFv8\r\nw8W7s6ZdhW5jR7dbYknXmMay95O92vNhoYoTzDvdy9uQqQwv1UzOetGYu81p\r\n86HQ25QTz/8HbKuurWPLHYOiQ0/PFkK+sZDsuc+Z7DALnhbf2+3/bKxzYIDT\r\nDUk76QTzWra1Z+7umzAcBjDjfiYm9rWH1Z4=\r\n=XGTT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"107ce1e5672bbf4a8084f2fe039036b9b29395e8","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.4","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.8_1653988343602_0.7735878745079938","host":"s3://npm-registry-packages"}},"6.0.9":{"name":"streamr-client","version":"6.0.9","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.9","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"timoxley","email":"secoif@gmail.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"bc1cfb62c2d2361411a665a59f8643397cc78eb5","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.9.tgz","fileCount":261,"integrity":"sha512-RBZRqkBsrSQEANR/qHVgLssra01kecXumAg9PKw+QP2bU3xP1ADItKx8o/L9C0p6MxNJ32I98Xdi38PF+8ejmA==","signatures":[{"sig":"MEUCIQC2a6DXYOmDRt7W1a4bY7iaVJPSH+i5m2oho7hOCLfB8wIgHqxTpYAl6MCjhRZ36JYYy5EYeWZnkvAC/6lO4sZ4Usc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22655200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJisDs6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpttw//bsKYCGCE5IHKmwBTUFPgPdZ017caBKYntZJxhlIZVm8M5Az7\r\nRu+o0ljvfc6Idg5K1zo/rq253bvSbjnTOn2XVW73jH+I7q8i5mXE5ZutF/SU\r\nQUJQC8szhpS/V55xz9ivhc9zY5tO1qJFCbo0Agi6tXZgr3+mrFI0BxDm01b0\r\npYfxzjjsIIGajJ+9WnjePPUd7UHHORc088UugMuBRWCw4AQh0zrIGzVyJ3bI\r\nXj8zLf6iisS7g0PQnbAn/uapx1HOvGjAev6IpY7RQ5cUWYRGWBOBcKQKfj3U\r\nVcPpnD6utJcz1LsxWpj6nytCLZVPy+0xKFj9aWf8kWbmA5uMZV6olrZFZgvm\r\nIjGIBxcuPnB2lX3F+H5BWVEncHsyVxHUFHCz01d0ygFrDDmhuqWgSQmB/iBf\r\nMl+Xmou0xmCtC3k+IRqbY/ftCZCd0fOl5N6v39YbK6C7yniGo11hz7yDtIgk\r\npMtghW4Qq/QfLD+6sknLmo/N8wJzhDKDTSGj3aD0sWAox71m+HTmd/AWWMr4\r\n5SUr2kksOA9Inyk7thlAO305im0W0oSu4QkZW8oG+vGaVBZEE8owrBYzQaiA\r\nldu4O/SQZPVhvdF3BGf1aZHsD0Ot2SZ6fXkJgxgQAcAprOhkhdBioZ3geYiT\r\nk6hi5KhO63palpiHy8CPNVI7E19llrdNjRI=\r\n=OAA0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"0a447120c0977a557a7dca5b33d479d5ff0a16c8","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.5","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.9_1655716666356_0.6364381190346384","host":"s3://npm-registry-packages"}},"6.1.0-beta.1":{"name":"streamr-client","version":"6.1.0-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-beta.1","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"65c490f206111e8b7012a425bbb017ababb0033c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-beta.1.tgz","fileCount":264,"integrity":"sha512-WX6+aXsQzVeGbEZqEqbI356rd2NZyBdZeRCL3JFTTH7Rc6GX/QNsVoXTHd+oqGRveux8i0d3fseTpGIcBl4qjQ==","signatures":[{"sig":"MEUCIDmnM5SQJ2gwbydg7AtVLrq9h85jHXuxVW1beQA203tvAiEA0utRKOSLKhspovhHKU+ygyGc3tG2ZEQmWXwrMdnu5Ok=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22693540,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizpjAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqi5g/8DuytkArflerIcjKnZBy1SbpaZgGzbXmYpyBEZhICpyQ3c4IV\r\naqOBGEnDUrDxZYl004I8+yhFgJw+/aSHMsxzj/pFivsrFG6wnK+3Zcmp+u+s\r\nd5GXwdKh/pqlYcHKVk+nGwCVmgNv+Y82hqX4tVcOUx4hOSJrxef1Sz+ombrz\r\nFz3nqYEeUooVF3br9wnw5LMAFy/oCr3DJc1MgbsdGVGZ+pzbaXkjgF3Yb1wg\r\nqDn7YnVvfjgRTP8tpKur8L533+1xonQ1+8muPurQn3GIiRxErSyIFTPMU1w5\r\nekYfZnVuMTqP2keDEuYTf990WSW/Srbe4+JToIEwZm26x1ZAcsvaHgZAk7rm\r\nhwD/S2NW5tlbfWLeTFD3SywJ1D8G1ypAqvzqaA16ZjdHgE/mMLcMSI1sepXB\r\nXPpm8t2N0R8iaN8/Sgg52BM2of50fHuO0QtMbH4I1CPz3sl+g8yzjcSP3R5d\r\nRMYX2A8sF3/yysY8WPub5oSt6TqjZezS7V8UA45NM0zUqASTNZi18f33LeOq\r\n8g1jthpZdGH6vnxGrn53NPtWilwhotN7gsJ2Nm7iu1cDXuNgJC1A207CUGe0\r\n5lpURkG9OFxXz/ujE9hCdkQ3nEOZwm4xdlpwYA8BuVYPKI/092lTB2seJh3m\r\nWwTYVqsNoQDarrVOpDg+MvBE8NsabG1JiKU=\r\n=Dikr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.13.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n    - [Enabling storage](#enabling-storage)\n    - [Data Unions](#data-unions)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Proxy publishing](#proxy-publishing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js \nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js \n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network. \n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId, \n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, will contain the value given to the `publish` method. \n\nThe second parameter `metadata` is of type `StreamMessage`. It contains metadata about the message, e.g. timestamp. \n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, new Date(1546300800123))\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, 1546300800123)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, '2019-01-01T00:00:00.123Z')\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    }, \n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...', \n        msgChainId: 'ihuzetvg0c88ydd82z5o', \n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.onResent(() => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription. \n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js \nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js \nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream permissions\n\nThere are 5 different permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```        \n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nstream.description = 'New description!'\nawait stream.update()\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n\n### Data Unions\n> ⚠️ This code examples in this section are not up to date.\n\nThe Data Union framework is a data crowdsourcing and crowdselling solution. Working in tandem with the Streamr Network and Ethereum, the framework powers applications that enable people to earn by sharing valuable data. You can [read more about it here](https://streamr.network/docs/data-unions/intro-to-data-unions)\n\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await streamr.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await streamr.getDataUnion('0x12345...')\n```\n\n\n#### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermissions()`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermissions()`.\n\nAdding members:\n```js\nconst receipt = await dataUnion.addMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\nRemoving members:\n```js\nconst receipt = await dataUnion.removeMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\n\nChecking if an address belongs to the Data Union:\n```js\nconst isMember = await dataUnion.isMember('0x12345...')\n```\n\nSend all withdrawable earnings to the member's address:\n```js\nconst receipt = await dataUnion.withdrawAllToMember('0x12345...')\n```\nSend all withdrawable earnings to the address signed off by the member:\n```js\nconst recipientAddress = '0x22222...'\n\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x11111...', // member address\n    recipientAddress,\n    signature\n)\n```\nSend some of the withdrawable earnings to the address signed off by the member\n```js\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x12345...', // member address\n    recipientAddress,\n    signature\n)\n\n// Or to authorize a fixed amount:\nconst receipt = await dataUnion.withdrawAmountToSigned(\n    '0x12345...', // member address\n    recipientAddress, \n    100, // token amount, in wei \n    signature, \n)\n```\n\nSetting a new admin fee:\n```js\n// Any number between 0 and 1, inclusive\nconst receipt = await dataUnion.setAdminFee(0.4) \n```\n#### Query functions\nThese are available for everyone and anyone, to query publicly available info from a Data Union.\n\nGet Data Union's statistics:\n```js\nconst stats = await dataUnion.getStats()\n```\nGet a member's stats:\n```js\nconst memberStats = await dataUnion.getMemberStats('0x12345...')\n```\nGet the withdrawable DATA tokens in the DU for a member:\n```js\n// Returns a BigNumber\nconst balance = await dataUnion.getWithdrawableEarnings('0x12345...')\n```\nGetting the set admin fee:\n```js\nconst adminFee = await dataUnion.getAdminFee()\n```\nGetting admin's address:\n```js\nconst adminAddress = await dataUnion.getAdminAddress()\n```\n\nGetting the Data Union's version:\n```js\nconst version = await dataUnion.getVersion()\n// Can be 0, 1 or 2\n// 0 if the contract is not a data union\n```\n\n#### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters. The provided values are the default ones, used when not specified or when the options parameter is not provided:\n```js\nconst receipt = await dataUnion.withdrawAll(\n    ...,\n    {\n        sendToMainnet: true, // Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)\n        payForTransport: true, //Whether to pay for the withdraw transaction signature transport to mainnet over the bridge\n        waitUntilTransportIsComplete: true, // Whether to wait until the withdrawn DATA tokens are visible in mainnet\n        pollingIntervalMs: 1000, // How often requests are sent to find out if the withdraw has completed, in ms\n        retryTimeoutMs: 60000, // When to give up when waiting for the withdraw to complete, in ms\n        gasPrice: /*Network Estimate*/ // Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge\n    }\n)\n```\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n#### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters. All shown values are the defaults for each property:\n```js\nconst ownerAddress = await streamr.getAddress()\n\nconst dataUnion = await streamr.deployDataUnion({\n    owner: ownerAddress, // Owner / admin of the newly created Data Union\n    joinPartsAgent: [ownerAddress], // Able to add and remove members to/from the Data Union\n    dataUnionName: /* Generated if not provided */, // NOT stored anywhere, only used for address derivation\n    adminFee: 0, // Must be between 0...1 \n    sidechainPollingIntervalMs: 1000, //How often requests are sent to find out if the deployment has completed\n    sidechainRetryTimeoutMs: 60000, // When to give up when waiting for the deployment to complete\n    confirmations: 1, // Blocks to wait after Data Union mainnet contract deployment to consider it final\n    gasPrice: /*Network Estimate*/ // Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract\n})\n```\n\nStreamr Core is added as a `joinPartAgent` by default so that joining with secret works using the member function `join`. If you don't plan to use `join` for \"self-service joining\", you can leave out Streamr Core agent by calling `deployDataUnion` e.g. with your own address as the sole joinPartAgent:\n```js\nconst dataUnion = await streamr.deployDataUnion({\n    joinPartAgents: [ownerAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed. Data Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means a Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n### Utility functions\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`. \n```js \nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = { \n    id: `${address}/foo/bar`, \n    partition: 4 \n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg, \n    Date.now(), \n    msg.vehicleId // msg.vehicleId is the partition key here\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Proxy publishing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, '0x12345...')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['0x11111...', '0x22222...'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, '0x12345...')\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['0x11111...', '0x22222...'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n### Logging\n\nThe library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"8c51d4dda6b186fee64b349bc37f173b1e804cc8","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.5","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-beta.1_1657706688444_0.9475764689394952","host":"s3://npm-registry-packages"}},"6.1.0-beta.2":{"name":"streamr-client","version":"6.1.0-beta.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-beta.2","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0f31be4e0fe288b94c5334730cbc3ba083429012","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-beta.2.tgz","fileCount":264,"integrity":"sha512-i/LN7NkzvA1x0plj5ULl3ZMf2Wx4bjiMEMS/jgY4MzsgV4/xPSyv7MFgCPdIy0PqWpvODm75knqVUCoCvy1S0w==","signatures":[{"sig":"MEUCIQDynB/h9XbHIECC3Z+NM9AXj6gHikln2Q7tp9Lfara4DwIgb0x/6a3pjTEMabi2JUmUeWiHFhVWF9AWDSC9ejmIAG0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22695254,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi48F6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoBIA//e8YvO/HaPuL03N1Ua+lXvFFB0JKqx0sScfD0r+wEVW4nZvKl\r\nUNE/gRvesCj9eTPCJczLY5SITnu77XqItwagR/9Py3+UFO3fx0Sq79oBcWnF\r\nE50SrOn2TPLFja1Mquia/jJU+7jR6uDGgvjcMNg6NhYfNPgaW7slnYdTGcZi\r\nlrDUDGMEYdphGpaie3mNik8tAVCM3KSrh358dWAXNtSgsSuKULZHrLfg5uBZ\r\n4JZ/lGzrp6RkwcpffBFhZ7bCZHUzoAyJ/Mdi1LHpoKLVrjQAr9Qn2oUQFfJP\r\njFf/qEpISQ5le0XL9L+7z3zahxT9mLu5cB63elE9mSyYFCG6NOxc9sRzpb5P\r\nPS8gFdkyuauQ6hQDeqWwKKjNPWNzAOFhpsmkL61X7iOnzC3wEy/nXDjcbmhl\r\nNdGAyF8S4424G9cq0WkzaL/RH8PmrujBr5is3d+8UndfI8bOFPsyKmFLwLsj\r\nEn76Iscd0059kyR3pqpE3eegwa98IFnMyrmadAEXsjCZUF+jK1gYTZsag3wV\r\natZKSzbTgrDR5W0JXMehW6uXM4+FmbkbD8VAJYXS91cqmliooKthQO6Tt2vc\r\nElH503yxPZx75FVdkZBObu1uL83lbsQnEa92Nz/iXjarOSWSM8ldbIbK4Zsh\r\n9Sdaqzm0fatSOURmHh51tZy03/fNx9br4eE=\r\n=Pbz8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.13.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n    - [Enabling storage](#enabling-storage)\n    - [Data Unions](#data-unions)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Proxy publishing](#proxy-publishing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js \nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js \n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network. \n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId, \n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, will contain the value given to the `publish` method. \n\nThe second parameter `metadata` is of type `StreamMessage`. It contains metadata about the message, e.g. timestamp. \n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, new Date(1546300800123))\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, 1546300800123)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, '2019-01-01T00:00:00.123Z')\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    }, \n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...', \n        msgChainId: 'ihuzetvg0c88ydd82z5o', \n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.onResent(() => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription. \n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js \nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js \nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream permissions\n\nThere are 5 different permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```        \n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nstream.description = 'New description!'\nawait stream.update()\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n\n### Data Unions\n> ⚠️ This code examples in this section are not up to date.\n\nThe Data Union framework is a data crowdsourcing and crowdselling solution. Working in tandem with the Streamr Network and Ethereum, the framework powers applications that enable people to earn by sharing valuable data. You can [read more about it here](https://streamr.network/docs/data-unions/intro-to-data-unions)\n\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await streamr.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await streamr.getDataUnion('0x12345...')\n```\n\n\n#### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermissions()`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermissions()`.\n\nAdding members:\n```js\nconst receipt = await dataUnion.addMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\nRemoving members:\n```js\nconst receipt = await dataUnion.removeMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\n\nChecking if an address belongs to the Data Union:\n```js\nconst isMember = await dataUnion.isMember('0x12345...')\n```\n\nSend all withdrawable earnings to the member's address:\n```js\nconst receipt = await dataUnion.withdrawAllToMember('0x12345...')\n```\nSend all withdrawable earnings to the address signed off by the member:\n```js\nconst recipientAddress = '0x22222...'\n\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x11111...', // member address\n    recipientAddress,\n    signature\n)\n```\nSend some of the withdrawable earnings to the address signed off by the member\n```js\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x12345...', // member address\n    recipientAddress,\n    signature\n)\n\n// Or to authorize a fixed amount:\nconst receipt = await dataUnion.withdrawAmountToSigned(\n    '0x12345...', // member address\n    recipientAddress, \n    100, // token amount, in wei \n    signature, \n)\n```\n\nSetting a new admin fee:\n```js\n// Any number between 0 and 1, inclusive\nconst receipt = await dataUnion.setAdminFee(0.4) \n```\n#### Query functions\nThese are available for everyone and anyone, to query publicly available info from a Data Union.\n\nGet Data Union's statistics:\n```js\nconst stats = await dataUnion.getStats()\n```\nGet a member's stats:\n```js\nconst memberStats = await dataUnion.getMemberStats('0x12345...')\n```\nGet the withdrawable DATA tokens in the DU for a member:\n```js\n// Returns a BigNumber\nconst balance = await dataUnion.getWithdrawableEarnings('0x12345...')\n```\nGetting the set admin fee:\n```js\nconst adminFee = await dataUnion.getAdminFee()\n```\nGetting admin's address:\n```js\nconst adminAddress = await dataUnion.getAdminAddress()\n```\n\nGetting the Data Union's version:\n```js\nconst version = await dataUnion.getVersion()\n// Can be 0, 1 or 2\n// 0 if the contract is not a data union\n```\n\n#### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters. The provided values are the default ones, used when not specified or when the options parameter is not provided:\n```js\nconst receipt = await dataUnion.withdrawAll(\n    ...,\n    {\n        sendToMainnet: true, // Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)\n        payForTransport: true, //Whether to pay for the withdraw transaction signature transport to mainnet over the bridge\n        waitUntilTransportIsComplete: true, // Whether to wait until the withdrawn DATA tokens are visible in mainnet\n        pollingIntervalMs: 1000, // How often requests are sent to find out if the withdraw has completed, in ms\n        retryTimeoutMs: 60000, // When to give up when waiting for the withdraw to complete, in ms\n        gasPrice: /*Network Estimate*/ // Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge\n    }\n)\n```\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n#### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters. All shown values are the defaults for each property:\n```js\nconst ownerAddress = await streamr.getAddress()\n\nconst dataUnion = await streamr.deployDataUnion({\n    owner: ownerAddress, // Owner / admin of the newly created Data Union\n    joinPartsAgent: [ownerAddress], // Able to add and remove members to/from the Data Union\n    dataUnionName: /* Generated if not provided */, // NOT stored anywhere, only used for address derivation\n    adminFee: 0, // Must be between 0...1 \n    sidechainPollingIntervalMs: 1000, //How often requests are sent to find out if the deployment has completed\n    sidechainRetryTimeoutMs: 60000, // When to give up when waiting for the deployment to complete\n    confirmations: 1, // Blocks to wait after Data Union mainnet contract deployment to consider it final\n    gasPrice: /*Network Estimate*/ // Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract\n})\n```\n\nStreamr Core is added as a `joinPartAgent` by default so that joining with secret works using the member function `join`. If you don't plan to use `join` for \"self-service joining\", you can leave out Streamr Core agent by calling `deployDataUnion` e.g. with your own address as the sole joinPartAgent:\n```js\nconst dataUnion = await streamr.deployDataUnion({\n    joinPartAgents: [ownerAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed. Data Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means a Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n### Utility functions\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`. \n```js \nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = { \n    id: `${address}/foo/bar`, \n    partition: 4 \n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg, \n    Date.now(), \n    msg.vehicleId // msg.vehicleId is the partition key here\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Proxy publishing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, '0x12345...')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['0x11111...', '0x22222...'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, '0x12345...')\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['0x11111...', '0x22222...'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n### Logging\n\nThe library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"4fab60a16cc9d9db209ceba7c6d393704c5b2416","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.5","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-beta.2_1659093370654_0.6709193442117101","host":"s3://npm-registry-packages"}},"6.1.0-beta.3":{"name":"streamr-client","version":"6.1.0-beta.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-beta.3","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"117b6f1166a6517416deb0418bb9c6fcf793e97a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-beta.3.tgz","fileCount":264,"integrity":"sha512-VISy8tLWd6WAC6gmBbwYgfU6G2faf8p/dVNfC9MUCJn/TvcEeG2FRMmaQCcpxhE7PZ2++hQaKBEtT+ALwAdEhA==","signatures":[{"sig":"MEQCIDuRCSn34jhgYfBpgrYWXLNmnqpkEiil5eKeZSokfrq/AiBK9dWpR6zx74YyIeim3bmTmJYuX3kS+ld6YW75SlT0BA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22697118,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjIF+1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr3IhAAgUov4yjPgSsWyXdfF+ycMjBMmaBaE+Wqz9iiChh4Z6xEnfgU\r\n61XqjdojTBJenwZmhLnWwl4IkjUeVxaOAmMC6yUp1EEbueC2jI0ws39sJu4c\r\nze89a7jvkd9BVkiIYrQDRqt5GfxYUsLSIy+1PkTEHCIHS4Fh4PlMUsNoFTUT\r\nGXhxFFE6GTRZgAhcMQqFFQ1ZbgYn7bkM3JrHL/3o5vXOgAkpiQhd5JtX17js\r\nGqYdy4u0TGZDIXzU8K069YjsWyBB0ntlJBMCWgQ6b6JC0yovS8HxK25lYYI+\r\nJ+Puq5y9okjjbKQONfbh3o0KIkrt5IqErpOGO30sZbn2Rb6lIQTEZB+8nRBL\r\nm58FlgY4FAAMs5Q/hWRGGUe1Cp1Xwo4ndFV1MtiL/9enS7s4x1hXBepyN1vs\r\n+jHHJ0mdBr0mEVI/4imNzuNESQYcVh9afyN+/wL2vGioXB1908utRyHRT9qo\r\nwaYNebPY09hGJvYNOI0N5NpFb4S/oDNQO4/48kklglmjZqD2Pc7ocATGFVfQ\r\nbIFzdu+ZcUUAfJqOQsyP/uBaxoU7EgQwJlMGVVJcWiRxYco9IgXGNfeNWu7X\r\njCv+2HITN8aqcvd1DKgAJMZYucKFIRTHVZMQhsgr6gYcw7LEBgHwukquHKbJ\r\nuKwd87liX+CW3rjdks6tPb9waPTI7RcHnLk=\r\n=4Mg5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.13.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n    - [Enabling storage](#enabling-storage)\n    - [Data Unions](#data-unions)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Proxy publishing](#proxy-publishing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js \nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js \n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network. \n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId, \n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, will contain the value given to the `publish` method. \n\nThe second parameter `metadata` is of type `StreamMessage`. It contains metadata about the message, e.g. timestamp. \n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, new Date(1546300800123))\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, 1546300800123)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, '2019-01-01T00:00:00.123Z')\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    }, \n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...', \n        msgChainId: 'ihuzetvg0c88ydd82z5o', \n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.onResent(() => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription. \n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js \nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js \nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream permissions\n\nThere are 5 different permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```        \n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nstream.description = 'New description!'\nawait stream.update()\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n\n### Data Unions\n> ⚠️ This code examples in this section are not up to date.\n\nThe Data Union framework is a data crowdsourcing and crowdselling solution. Working in tandem with the Streamr Network and Ethereum, the framework powers applications that enable people to earn by sharing valuable data. You can [read more about it here](https://streamr.network/docs/data-unions/intro-to-data-unions)\n\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await streamr.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await streamr.getDataUnion('0x12345...')\n```\n\n\n#### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermissions()`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermissions()`.\n\nAdding members:\n```js\nconst receipt = await dataUnion.addMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\nRemoving members:\n```js\nconst receipt = await dataUnion.removeMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\n\nChecking if an address belongs to the Data Union:\n```js\nconst isMember = await dataUnion.isMember('0x12345...')\n```\n\nSend all withdrawable earnings to the member's address:\n```js\nconst receipt = await dataUnion.withdrawAllToMember('0x12345...')\n```\nSend all withdrawable earnings to the address signed off by the member:\n```js\nconst recipientAddress = '0x22222...'\n\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x11111...', // member address\n    recipientAddress,\n    signature\n)\n```\nSend some of the withdrawable earnings to the address signed off by the member\n```js\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x12345...', // member address\n    recipientAddress,\n    signature\n)\n\n// Or to authorize a fixed amount:\nconst receipt = await dataUnion.withdrawAmountToSigned(\n    '0x12345...', // member address\n    recipientAddress, \n    100, // token amount, in wei \n    signature, \n)\n```\n\nSetting a new admin fee:\n```js\n// Any number between 0 and 1, inclusive\nconst receipt = await dataUnion.setAdminFee(0.4) \n```\n#### Query functions\nThese are available for everyone and anyone, to query publicly available info from a Data Union.\n\nGet Data Union's statistics:\n```js\nconst stats = await dataUnion.getStats()\n```\nGet a member's stats:\n```js\nconst memberStats = await dataUnion.getMemberStats('0x12345...')\n```\nGet the withdrawable DATA tokens in the DU for a member:\n```js\n// Returns a BigNumber\nconst balance = await dataUnion.getWithdrawableEarnings('0x12345...')\n```\nGetting the set admin fee:\n```js\nconst adminFee = await dataUnion.getAdminFee()\n```\nGetting admin's address:\n```js\nconst adminAddress = await dataUnion.getAdminAddress()\n```\n\nGetting the Data Union's version:\n```js\nconst version = await dataUnion.getVersion()\n// Can be 0, 1 or 2\n// 0 if the contract is not a data union\n```\n\n#### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters. The provided values are the default ones, used when not specified or when the options parameter is not provided:\n```js\nconst receipt = await dataUnion.withdrawAll(\n    ...,\n    {\n        sendToMainnet: true, // Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)\n        payForTransport: true, //Whether to pay for the withdraw transaction signature transport to mainnet over the bridge\n        waitUntilTransportIsComplete: true, // Whether to wait until the withdrawn DATA tokens are visible in mainnet\n        pollingIntervalMs: 1000, // How often requests are sent to find out if the withdraw has completed, in ms\n        retryTimeoutMs: 60000, // When to give up when waiting for the withdraw to complete, in ms\n        gasPrice: /*Network Estimate*/ // Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge\n    }\n)\n```\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n#### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters. All shown values are the defaults for each property:\n```js\nconst ownerAddress = await streamr.getAddress()\n\nconst dataUnion = await streamr.deployDataUnion({\n    owner: ownerAddress, // Owner / admin of the newly created Data Union\n    joinPartsAgent: [ownerAddress], // Able to add and remove members to/from the Data Union\n    dataUnionName: /* Generated if not provided */, // NOT stored anywhere, only used for address derivation\n    adminFee: 0, // Must be between 0...1 \n    sidechainPollingIntervalMs: 1000, //How often requests are sent to find out if the deployment has completed\n    sidechainRetryTimeoutMs: 60000, // When to give up when waiting for the deployment to complete\n    confirmations: 1, // Blocks to wait after Data Union mainnet contract deployment to consider it final\n    gasPrice: /*Network Estimate*/ // Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract\n})\n```\n\nStreamr Core is added as a `joinPartAgent` by default so that joining with secret works using the member function `join`. If you don't plan to use `join` for \"self-service joining\", you can leave out Streamr Core agent by calling `deployDataUnion` e.g. with your own address as the sole joinPartAgent:\n```js\nconst dataUnion = await streamr.deployDataUnion({\n    joinPartAgents: [ownerAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed. Data Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means a Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n### Utility functions\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`. \n```js \nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = { \n    id: `${address}/foo/bar`, \n    partition: 4 \n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg, \n    Date.now(), \n    msg.vehicleId // msg.vehicleId is the partition key here\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Proxy publishing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, '0x12345...')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['0x11111...', '0x22222...'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, '0x12345...')\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['0x11111...', '0x22222...'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n### Logging\n\nThe library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"d0068d74bb5688bb4673973cd2e26f3047ddcbcc","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.5","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-beta.3_1663066036682_0.4476290430294241","host":"s3://npm-registry-packages"}},"6.1.0-beta.4":{"name":"streamr-client","version":"6.1.0-beta.4","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.1.0-beta.4","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"df984909e1c1c287f8825664f75e18db7189b4d0","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.1.0-beta.4.tgz","fileCount":264,"integrity":"sha512-3OkYouOaKya/vDIkm1XVy/aEaBSzuSw5X/c+uuMWgwPyxpHwbaqp/+ATzOmnK4HvndhX6mrKmYJivV91pPQmHg==","signatures":[{"sig":"MEUCIQDEYOW4dsMAES56Y8IitRvDdTXAKqE2ANOgxf2FyUySEQIgE+vwmpkuj4FK5dDNUmm3rPHBYlgO8A7xJmtSAIzxKWY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22696887,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjNtnYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpSjQ//bMn0AyEh5Y9qQtV1L801gMNe1PyzlfjZD5uRFCkX/HqpmLaC\r\nJ554ZQwWTZqIyoIxEGEhtXZBAAsEP075Kk38J1dqVxk1UcV93MOTYlCi6iIO\r\nloYtzKd9cpWB7J74iP/mIytXgez5HonHgpQNcsWGc7HaNYoMbvTGzyc/ttWj\r\n6pU8OE0+zja+dMm5mGm5ov+hP4W7gouwqyjXVZA/aH5IhHrl8JUdNxiR1lXm\r\nFBrAwlwnk5R37DJ0xo+M5jQCTgqdIrvA0gTkiM0a1lhBi9xQZqktaKHttUNw\r\ndFE6OA+MtBlcS1VZ3eOYetrCY2xyBsu/hS2kFu8z0eQbDv+h0LsybRaR32yI\r\nj2UlcojP8vbGYvNLxbbVMrHAwnWsa4ocsb1xxsXm1FYxnX6qy3U2ALPBOIOr\r\ngGk5GTtz9uLqikdSh6NvX7maGM/4pWR5/23wNFk2Z5QBkYWGYCklj62E+dEs\r\nQPOwAVitjIaV1yB/PAvdRxrQ8NZl6hinQzngcXbEqorj1H9ii/7K2zCVX9/E\r\n0YsYRHbbeMmtnECFOLsQVONj0FnXFNg8VINp0QtL73rMzSVS2gAWaNt23KmG\r\nWMAt6Wrwuezlc7XWm5Uaq2Og9oTvC/Sjs8Rc/YvJQryENP1QME50jpK45Qtp\r\n2xeCwLgWB3RdYo1du0BbdOCuSocnaopCM0w=\r\n=9z26\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.13.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n    - [Enabling storage](#enabling-storage)\n    - [Data Unions](#data-unions)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Proxy publishing](#proxy-publishing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js \nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js \n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network. \n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId, \n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, will contain the value given to the `publish` method. \n\nThe second parameter `metadata` is of type `StreamMessage`. It contains metadata about the message, e.g. timestamp. \n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, new Date(1546300800123))\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, 1546300800123)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, '2019-01-01T00:00:00.123Z')\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    }, \n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...', \n        msgChainId: 'ihuzetvg0c88ydd82z5o', \n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.onResent(() => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription. \n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js \nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js \nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream permissions\n\nThere are 5 different permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```        \n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nstream.description = 'New description!'\nawait stream.update()\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n\n### Data Unions\n> ⚠️ This code examples in this section are not up to date.\n\nThe Data Union framework is a data crowdsourcing and crowdselling solution. Working in tandem with the Streamr Network and Ethereum, the framework powers applications that enable people to earn by sharing valuable data. You can [read more about it here](https://streamr.network/docs/data-unions/intro-to-data-unions)\n\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await streamr.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = await streamr.getDataUnion('0x12345...')\n```\n\n\n#### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermissions()`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermissions()`.\n\nAdding members:\n```js\nconst receipt = await dataUnion.addMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\nRemoving members:\n```js\nconst receipt = await dataUnion.removeMembers([\n    '0x11111...',\n    '0x22222...',\n    '0x33333...',\n])\n```\n\nChecking if an address belongs to the Data Union:\n```js\nconst isMember = await dataUnion.isMember('0x12345...')\n```\n\nSend all withdrawable earnings to the member's address:\n```js\nconst receipt = await dataUnion.withdrawAllToMember('0x12345...')\n```\nSend all withdrawable earnings to the address signed off by the member:\n```js\nconst recipientAddress = '0x22222...'\n\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x11111...', // member address\n    recipientAddress,\n    signature\n)\n```\nSend some of the withdrawable earnings to the address signed off by the member\n```js\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(\n    '0x12345...', // member address\n    recipientAddress,\n    signature\n)\n\n// Or to authorize a fixed amount:\nconst receipt = await dataUnion.withdrawAmountToSigned(\n    '0x12345...', // member address\n    recipientAddress, \n    100, // token amount, in wei \n    signature, \n)\n```\n\nSetting a new admin fee:\n```js\n// Any number between 0 and 1, inclusive\nconst receipt = await dataUnion.setAdminFee(0.4) \n```\n#### Query functions\nThese are available for everyone and anyone, to query publicly available info from a Data Union.\n\nGet Data Union's statistics:\n```js\nconst stats = await dataUnion.getStats()\n```\nGet a member's stats:\n```js\nconst memberStats = await dataUnion.getMemberStats('0x12345...')\n```\nGet the withdrawable DATA tokens in the DU for a member:\n```js\n// Returns a BigNumber\nconst balance = await dataUnion.getWithdrawableEarnings('0x12345...')\n```\nGetting the set admin fee:\n```js\nconst adminFee = await dataUnion.getAdminFee()\n```\nGetting admin's address:\n```js\nconst adminAddress = await dataUnion.getAdminAddress()\n```\n\nGetting the Data Union's version:\n```js\nconst version = await dataUnion.getVersion()\n// Can be 0, 1 or 2\n// 0 if the contract is not a data union\n```\n\n#### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters. The provided values are the default ones, used when not specified or when the options parameter is not provided:\n```js\nconst receipt = await dataUnion.withdrawAll(\n    ...,\n    {\n        sendToMainnet: true, // Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)\n        payForTransport: true, //Whether to pay for the withdraw transaction signature transport to mainnet over the bridge\n        waitUntilTransportIsComplete: true, // Whether to wait until the withdrawn DATA tokens are visible in mainnet\n        pollingIntervalMs: 1000, // How often requests are sent to find out if the withdraw has completed, in ms\n        retryTimeoutMs: 60000, // When to give up when waiting for the withdraw to complete, in ms\n        gasPrice: /*Network Estimate*/ // Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge\n    }\n)\n```\n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first |\n\n#### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters. All shown values are the defaults for each property:\n```js\nconst ownerAddress = await streamr.getAddress()\n\nconst dataUnion = await streamr.deployDataUnion({\n    owner: ownerAddress, // Owner / admin of the newly created Data Union\n    joinPartsAgent: [ownerAddress], // Able to add and remove members to/from the Data Union\n    dataUnionName: /* Generated if not provided */, // NOT stored anywhere, only used for address derivation\n    adminFee: 0, // Must be between 0...1 \n    sidechainPollingIntervalMs: 1000, //How often requests are sent to find out if the deployment has completed\n    sidechainRetryTimeoutMs: 60000, // When to give up when waiting for the deployment to complete\n    confirmations: 1, // Blocks to wait after Data Union mainnet contract deployment to consider it final\n    gasPrice: /*Network Estimate*/ // Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract\n})\n```\n\nStreamr Core is added as a `joinPartAgent` by default so that joining with secret works using the member function `join`. If you don't plan to use `join` for \"self-service joining\", you can leave out Streamr Core agent by calling `deployDataUnion` e.g. with your own address as the sole joinPartAgent:\n```js\nconst dataUnion = await streamr.deployDataUnion({\n    joinPartAgents: [ownerAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed. Data Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means a Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n\n### Utility functions\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`. \n```js \nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = { \n    id: `${address}/foo/bar`, \n    partition: 4 \n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg, \n    Date.now(), \n    msg.vehicleId // msg.vehicleId is the partition key here\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Proxy publishing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nProxy publishing is done on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n// Open publish proxy to a node on stream\nawait publishingClient.setPublishProxy(stream, '0x12345...')\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.setPublishProxies(stream, ['0x11111...', '0x22222...'])\n\n// Remove publish proxy to a node on stream\nawait publishingClient.removePublishProxy(stream, '0x12345...')\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.removePublishProxies(stream, ['0x11111...', '0x22222...'])\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections.\n\n### Logging\n\nThe library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"a7e99ae2e7159bf9547df6633819286b09e2787f","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.5","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.1.0-beta.4_1664539095998_0.012012743691890648","host":"s3://npm-registry-packages"}},"6.0.10":{"name":"streamr-client","version":"6.0.10","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@6.0.10","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"0c2d1f0bbab1fb26153f5aa7bfa37ca11719808e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-6.0.10.tgz","fileCount":261,"integrity":"sha512-VqwmWh+0vfFp38QVVCnCu5eEuGLG6J54F2S9o68tbWZ6/g12N81l3ACePEk9mgWNyqwJxQHpEyOV43XmU6Qhig==","signatures":[{"sig":"MEUCIQCdniu0v04qodZfnR/ZSkFlTkeI+mAFUYLFx4Nvr9/ZBAIgIQyLJ1HgEXvyWMDzlqVikRiuaABJB4PSPRNmB3QQuJk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22655746,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOsR+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoUWw//YK4GvwQ2zh0FTxC7I39vYmMIcI4Db+oJ/D/3IkTIbNhU4L6I\r\n07//6SKPiA1lxRPMU5vzBAaX9wh29CmjxXy7AMKGfZHheCkDAYz1l1kAC8wf\r\nBkVpFle/LYp0YxFDlvROw02ACmjuc22jNWqxjxML8Zmfab199Lhy0is1YHB3\r\nBnyf/RgGBDTRszMZqPNKxIw8gtn3XqKQjuzEvswLh92i77Biyc/QB6f6rNwA\r\nx/7OQRNFqX/FZWPrA73iVcRjjWXZ3UdI/ZjMSEeaGr6ItP1aaEZ5lO6hgUqB\r\neVWSv8fT8oIGQ2I7D3o6RKQjyBXlzJIpFWgJY4lFruc5ZBhuLvfxAH8Co8Wp\r\n9C5JS5Rw4ZHyPl8iauAOPePml8d0JG70E44WnbcN4VvZ/l8Ag1nEUQSGll+U\r\ngAx7etxiZEV9qGTWjszTK/yNT4OrBPCqaUEDCc7hlDlOzxn+mLLpozh7dlEH\r\nikbnDgDRT8TPE2wqW1dca4wP1wUIQ72k1uxTgTB//Zq+Zbhw1DYzHCJa2atc\r\nQzO8m0M7Bsbo3qZUUzmcK6l9EKvTAvUpyCo9/oPEUHJvUssgtovQGffhp8Aa\r\nbcZyXB40KJ6weGcXqzQZolSqqsJA1WXMamOiwF+WrNX6cNPJ9CDbDc/RnQPU\r\nHHvZ5n7ydlCm8GIvvmhZRtkvaQ9Hq3Nk8EY=\r\n=YWxJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"8cfac89b0f028bcde32deaf1a90858e24855fd5b","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.2","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^35.0.5","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.5.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^12.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/keccak256":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"cors":"^2.8.5","jest":"^27.2.5","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","eslint":"^7.32.0","ethers":"^5.4.7","express":"^4.17.1","process":"^0.11.10","ts-jest":"^27.0.5","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.2.6","weak-napi":"^2.0.2","nightwatch":"^1.7.12","typescript":"^4.5.2","@babel/core":"^7.16.0","@types/jest":"^27.0.2","@types/node":"^16.10.6","@types/uuid":"^8.3.1","jest-circus":"^27.2.5","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^98.0.0","concurrently":"^6.4.0","pretty-bytes":"^5.6.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","eslint-loader":"^4.0.2","webpack-merge":"^5.8.0","@types/express":"^4.17.13","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.25.3","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","@typescript-eslint/parser":"^5.0.0","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.1","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^5.0.0","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_6.0.10_1664795774053_0.5736049944924557","host":"s3://npm-registry-packages"}},"7.0.0-beta.0":{"name":"streamr-client","version":"7.0.0-beta.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.0-beta.0","maintainers":[{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"830f84e652796a9fc1fdbfb10e8aa72a844fb011","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.0-beta.0.tgz","fileCount":277,"integrity":"sha512-10G/VobXVB5dJgmmyOC6LnbE5R7W5ii5d9R2ywgRJZY6f5EFHTcq/LR/WUMoL7L26yFDZ1bfZjLwhGA9zd1feg==","signatures":[{"sig":"MEYCIQDcGNtCukVhGqfo2zLttOkKwRylsPR9/PWYpVxQjFj9igIhAKqKS5QNbWtJTJFcHGRyVwiK4f70A34P6uh0vRoPKvv3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21938570,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjR+whACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3tg//WCPqB04mda7ArMqVaE2RNrRId238xqg4FfiOYtHRLIfmh3cL\r\nFIVDzRfvi65os2+r5rg91iKslWxxoD5t5Q1EKKEtUOvZszNbT5usCgrfLrXn\r\nt2gFvYCE4ON/V23qUC9T2HJYXBXyZCv+c79YImvmkquYjj6a30PBz7UJaAdt\r\nlRO5BE+94e//hwLk1wROAw2bpg48hVd7a5YnuYqeWSsRgechV6F51hHAREbk\r\n+i6UuBzeHvqimt/OkWEqSIXTMB2DMNYXNdJDiTfyD4PdNc4FEsV0cK5pcOQg\r\nRETIUPvOfy5WCv4uYWEpLlGAe1M3YU0Z8E262joPRREP60lx8ikSv+FZF5r8\r\nEAEMervExLuXzWt47lf5tKNnQVI/ysiwN7lRGz3S7m/5+zdMssxce3oLwj8G\r\nxnKkuyKOgDOEgfJ9/9Vyyi1044c9Rxk9GtXezrvowOaesJees5C3XgzkgGmw\r\nmX/hpt3cMpZhMTEtJTkuOts2zhKFJgYgY6gXM++xjl6mminDizZ0i7Eh082S\r\nruswywISoGlcT0eHbWVVL4f5e5RvFY+hlSK6bGUYm2EYodeZ30u5Xb+5+GkX\r\nYaVfzfuHeqw4RDO7HC0Tg9OztfbWOMLUlEFvcg4AUGWEjpFoLNnXyWKEkp3F\r\nldXIYZpMz/uzio0Xw3lhupy3SDNvNtKiE14=\r\n=Psha\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.14.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n     - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, will contain the value given to the `publish` method.\n\nThe second parameter `metadata` is of type `StreamMessage`. It contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n        \n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThe library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"39421e2d88e9791a058a7c3006988b6491565b29","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","@types/debug":"^4.1.7","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"^1.0.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","streamr-network":"^36.0.0","reflect-metadata":"^0.1.13","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","streamr-client-protocol":"^13.0.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.22.5","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/node":"^16.10.6","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^105.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","streamr-test-utils":"^2.0.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.0-beta.0_1665657889458_0.3564154429141366","host":"s3://npm-registry-packages"}},"7.0.0-beta.1":{"name":"streamr-client","version":"7.0.0-beta.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.0-beta.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"6224e93657534d8ff800de17f83d5aad9c23e1d0","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.0-beta.1.tgz","fileCount":283,"integrity":"sha512-iqoLPhWHDNytVMTcOtJ3WMFFKhqARgPuKOwY64qPuTmYvULHHtM0O5BHz4Bw6xmXWLWOUV5LQVnDOCfCpQMnoA==","signatures":[{"sig":"MEQCIHyzknIKVq7kPa4mhciZ4mrC51QzoO02EiRvFZidNZlHAiAqSNKVUfOi0+O1roxfX8wIqcIkWg1X+MwW/A66DSsvdg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21792376,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjaSPRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpEAw//QJ2nzLERu9wUJYTP9ekZbUUtHEwMQq2fkAxcH3m20RUhXWzQ\r\nqavpqhrKuUoHapW4vF/LsLyS7YY6agGM5/lNFZtOXivPjvyH20HNTIz9Cym2\r\nyNM67qmW3JGIZZsBbHtzHnjG9D493WsGOTmDRE9GIbscO9Bxf0lLjDNlyVUU\r\nc+3unC7zp+nuXbNTkHDdZY5VC0szUj02uj+WsthEqCb2edHqYiTQQ55ZMckl\r\nRuDMFaRVgKnShdO4gtvPwrMI2KCyHo1FkWSMbEeGZo/rSRzy/7Md955K4gQU\r\nv2g94c1YHdW8WXlhNSjsKsK86yW8AodM+XAMyD4iMTOkUxNbXbJ0imUSB+LM\r\nXTb52VXI9AqDTXZEaOc8bFvzzsfox6VOUVqF849UNqU2G1HCXCvZhxbl6XtF\r\nYOU3mgPA/UYae6HlgrsJ4qYW526E3W26Q5/EOYIBz7J2C/x6J3JMzbhKLa+X\r\n32uEUCQ58/j+Xr2SEy/iOD4qQXYbpxIZNdxCf41LSUaTSLLcBIdmx4mmZ5TU\r\nQdxLSBfsP7bdpl/YY55wy/vzI0YgsIg7/nvOH0F56VnKxnGCcS0P4Gm5kMGN\r\nmc1/qr5jxjp01sb2nTnnR0qt7Ab5eDWzA4RzihyfLQqvaZ8G8vEAlhdjO30p\r\nqf/pIoJkf+xj3G4QbdBkUJAvJtL1TAEM5Rg=\r\n=rhxv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.14.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n     - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"d42ded69763987e0eaf59ddefb25da3a8736342c","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.0-beta.1","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.0-beta.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.0-beta.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.0-beta.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.0-beta.1_1667834833174_0.521549813938907","host":"s3://npm-registry-packages"}},"7.0.0-beta.2":{"name":"streamr-client","version":"7.0.0-beta.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.0-beta.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"da03463a634965eb1a9a5e9bbf24cd80a170705c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.0-beta.2.tgz","fileCount":280,"integrity":"sha512-d3/BOmuh6YDmw7sWFVEM0hvydc4SFejdPc9uBVwrvrMrdqTKCTQleYH5GnzhE6zwghAEQszaF1G69Gu249/YSg==","signatures":[{"sig":"MEYCIQDt03GFzdROu1xx5Hwrt6dWa/PERlQXgv4ZMUXKhURrNQIhAP904wxuwUe0cODK1HNfQLdm+YsUPa0A3haehgpFBV8J","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21779705,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjalooACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpM6w/9GXo2yYKrFfn4h9Ldnpe8gG/dIgpTQTDrYkDgNeJwlqD1upBq\r\nByQaLoh5/8JJ+s+7WVkPe/mPb0VmoqozDn4VgmGHVOwsBlGCioBYZgNnLRFI\r\nSo4O0nxaR95/EIRCzU+KUd4+03hyR85bOboB9na+A52Lw4QbXm1RR+gkziQp\r\nEUjlseWdTXKsJApzgeuVjRwc/m/qZXoPnRxkQA97zFOSRXgG+SgOyt2dgTdS\r\n7B+Lc7nDC4wkt5raaWoLnp1DhnlrhrFIs7kU4tWt0B5+j5uM9O566enZWRLv\r\npV8NAN5S7Oij7/CSu8vcH6+eKY0IXhGWngZhdCT/TbkkxXCnSfpCc2wKP0XW\r\naYWGLMc+TKmUuEM0iewmlV0QT6Q0izEVARxvSSRZByTAf+kBclsGGjvS/w4W\r\nu0tjt3IphXoKBY7ALpJUbE7tEMArqp7q95m+vnLarOtiwcwBxVX/Dh9KSqNJ\r\nUGJmVYGT7MX1FU+gFz8BcxKLyGYXAC26o8tVxvxLH26bJwUybpnN/h0BBie0\r\nqgvvrKEUArlzQizL00zQEO0kEb5El4PvPFN2DNe3YrOquUBrsziV1pUNWq5p\r\n8TSEAQ9q67gbaPRAzxsLcasrTw+EaoNzmPzDuVbDdPcXPwfww/TahTQUTNmJ\r\nfJAB4G5hwKtAPWS6gSieLTMKEQouFI3dJ9k=\r\n=qfEw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.14.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n     - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"f1a913f4073da274fc1f85b0bde10c3e0b151649","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.0-beta.2","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.0-beta.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.0-beta.2","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.0-beta.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.0-beta.2_1667914280144_0.3013086727383425","host":"s3://npm-registry-packages"}},"7.0.0-beta.3":{"name":"streamr-client","version":"7.0.0-beta.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.0-beta.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"60563cbbfa285bd1d1727344dc75263864eb036a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.0-beta.3.tgz","fileCount":280,"integrity":"sha512-+xOhSmSNriMMcggabMJ4vhPLbHpLnb57xzUEVRzzTgNqKQ5tVdXce/M9M7BOh7dvaBO0oJbitZioC7uDvJRf9Q==","signatures":[{"sig":"MEUCIBOOPOh0xkN2Hz+WAo6E2NhMx4lewHhHcAKGwAThrNMQAiEA9490jnDm65AWBcQwgNKUyZfpAStnu+TQFN/pjsee6vc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21779584,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJja43bACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoNug//U5JUh4CaruXVPm+038BVOmcH6VKwKR1JpiTtmgbzhsBNN8tQ\r\nrUnrS5amm946LIBwBXG8WP7B4joavpKlBZ+Ln1t7s7ihPHcaRXCOCxDSF7P1\r\n9E6T8pXh/jkl6wDWaGwaByO3JHa8d9X9lZ55pa6qJy/Y8NgVkPmywXPagzyi\r\nmfVJJ96+TzHcFqjWkkOYlkiTCkBRNWzapSPHaUmhqKGCkKMq12BbsrirQmd4\r\nNUZouF+Ld3cPk6deIvi0UACJbAtP7zYUzSQbvt5lNrtbNiU3MfWfVGEjG6qk\r\nvfbKoI8raA18fDk0eywkEoJ3DlYPRH7kC5KaO0wXH8MzohvqhBqMKrZopAwm\r\nHFrvS4VEQTGKfoA2KoVOQ5uHKtOEBIBkd0/Fa/Ki0slYdISmX3bv4JBDNa6A\r\no/lBx0YssE7ln70PAXWaIIPXZ6XGzjIK0Rqhk251IHXWvPjRp1p03CfcsFGD\r\nUdswazb/JS25JV7jq/aAKbImcIx+K8ZkORrKXlNJKJt/s3Bxcz7y+o2P66NO\r\nBnuAtLNkAAtSqc0xbXEJBEQfov/lpSYfbL6PHLMmIoNTTeGfYcLolSr/CFRX\r\nIOdnXJxJOKhjZMkgmHgVD7DLy7pYRasrHdB33YRwedLFLExjC4ZwCo9bmbBp\r\nJauMS1pQY3AlJ5zlFXafIl1KI4at7Nd87fQ=\r\n=KQ8P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n[![Build status](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml/badge.svg)](https://github.com/streamr-dev/monorepo/actions/workflows/client-build.yml)\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\n| If you are using the Streamr Client in Node, NodeJS version `16.14.x` and NPM version `8.x` is required |\n| --- |\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n     - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"01a3634ff15876f33540edbc6594752502b61518","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.0-beta.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.0-beta.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.0-beta.3","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.0-beta.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.0-beta.3_1667993050804_0.6178864866487055","host":"s3://npm-registry-packages"}},"7.0.0":{"name":"streamr-client","version":"7.0.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"c47233236dc60793d8aec17341b941abc4e794aa","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.0.tgz","fileCount":280,"integrity":"sha512-/I4TtZkTXaRySd2EaPJYxyHF+0pYSPQRY7FMVdXW2VldkhuYQuxZiaJojd1UgqfRpBz8My3+vzJti5DFbEhIvg==","signatures":[{"sig":"MEQCID5uY2uJfPm1YJntHq5vesMppJiix9ntm/I8ZQTJT9TSAiAi9uS3jWsjgYZZ7Mzc2JiKerHO67+D9yZlzK02NJny3g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21794288,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjc5UOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqVARAAgDXGvrssrEzGNVryggqaIO0fnV6EEr9suYXj+uGPNw9wKeUR\r\np+JAZmJJOniYnFwuz/a1VJaJqzYaoWoHslxOfbOyLpuZ1dvAqkVMcKBgtoLg\r\nf92YCple6rWKP5+dTvwkqhw9sNcyWIKJ2UpFohffYR0oduQ6XiO8+FaTgOpD\r\nqqnurSeu6P/MOBXzQHJP4tIzTJ3R5F8hNI3Adt57PoxOBR1m79/184gfnotQ\r\nObk0pKb8ZkhTs7FmTbR02mFctsn+9hK393IyflU1hSMKdS6eshMg2GjmIPr1\r\nqkNdhaBuq2SfihlMIm46A7/uOWZQyCiklMc5UHQfN7wDSSa2fXglI9VvOISe\r\nABAInuguN0TFzOHfGaXfw0Ykk63GRmwMlD4i+Van974bdtkEzk9kvN9XoaQJ\r\nTmhG5jf52Tai+h/wfHfpwDo2YI+dCh6auEtMmAwEGN76vRgYDjjwwddKEytD\r\nD3YKVR82p3YhIWGQtmwVf6Xzvs8nvsbV2Qo79R0pEOg9vKFOfK2pFhfIoy7v\r\npZJUtYj7vNTDAHLdcp4fG9S5GsWLtZnhAFInTvHT9ozDdVLg4rfbGN63w3Zo\r\nM/UPON6Ash2wEOBxpzj6CPyThvZzFaufBeGazlRn6A3a0nF+U5kaUGal5164\r\n4mDxORfgbe97QCNvp+b2Vb1Er/2XU+e8tGw=\r\n=BY+g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"a461b8ecf2c511652e0aa3063b08c58b8adf79c0","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.0_1668519182609_0.011584933138343745","host":"s3://npm-registry-packages"}},"7.0.1":{"name":"streamr-client","version":"7.0.1","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"dd8cd67bec16f52463de4ee349ea0df850cad5d6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.1.tgz","fileCount":280,"integrity":"sha512-y46rdDMJVm79EtG653r4QIkT4t2bax8NLJtsN+5qX1cA+N/B+amoe3mG/J6HWrJJqnCeCue+uKFralPU8rzC3g==","signatures":[{"sig":"MEQCIC5pLM+hHPNBkjGatahkJc13nD/IYvA+um0jfg2KH22yAiA29LRfo+Tv7eCqYUws7AZtnWuwYAYBJgSytNgMN3rguA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21753058,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjd5eeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo5JQ/5AdU2pVGOerCIbKiKrTHpruZOiLMhpNzx1y1iMa1ire7HcZai\r\nV55vzzVK1B6Mb/MKP8+EGPP8y7mGDYkkX5Pexhr26HPqsLBlJi90Y3n2FIi6\r\nHZ0xWWMzI2CUD9xwcbEmtJskv2xbFQm/Q0X7rO8XnU9uSELHYLy/IPFMm2ci\r\n9FDTt2ciaVk7RMrCy7RNFNSdZoMBRFIhQeYKTcUZX3KOoJ2ssdwgQviIBxey\r\nmgqRebMzgC3Nh/SzFpPqwVUPz/GBFwODM1+Rd6xbFul2cQdVMe/QgXFKwBDV\r\n2ifwtAmC142CJ4X0g/OFzMzUwQvdG0/IF8qiJqE6zorabO7JEeD7k3Gdk8NV\r\naQGNfqEpSl78HpMCoPBQ3WS5JcJcxMiA3xgiF04Quofim2zI6ZCxxDDy5WQG\r\nvMJsaiIQAHLcNCRctUfSr0mUYfJ0VdgIwUTAHCEfqDN0liLn5NHZqxHetakM\r\nk1Q8zV4N0E70rlriHFK9xYa7IVofXwMXBDCXkfIKajPrPohdoG7vHwLSg30J\r\nUDVwx+xU/wfAqE1Jzc/6TvfJGydpjyFtVLhVM7ZWuwNNucvLscNK8GN1EpcT\r\nvH9f5WiRWN1G6NsTQYnH5PI/AD/8CNpKZYZVWWuNLVcmyEWABlc33ShpqaTv\r\ntF3RG8yHG42b/yDFzUobM7VTSqKZX0/htSA=\r\n=A77r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"16d3e9a3fb4acc1406dd428bad0081387161b546","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.1","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.1_1668781982525_0.46092615407357695","host":"s3://npm-registry-packages"}},"7.0.2":{"name":"streamr-client","version":"7.0.2","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"4a208a2b353858a105d4f0cc398ef4cd61c9089c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.2.tgz","fileCount":280,"integrity":"sha512-pEokexvZauWwTkuEIE8GHdHvSNmO6ywwpeAVYgBMFy1SnHU4aS+VmyUV2mU9ks/tOUVqLu3aBQH/UgIowLCb2g==","signatures":[{"sig":"MEUCIQCXqcHdFs7/Q+71RthL15C89sVQ1vRUhVr6b+UHXEXGAgIgfyBur0UGHBoZxNokwEd79mNVKqobpwvPJGS435sXZi0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21753788,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjfPnAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrK6A//UGrvnihuryDPYCq/DSNgPUnG5kX3DMBKAmmr+hWPKx2UrLr6\r\nKNZRiozQKgbtWrMbsj2N7iTh0ieHXksR7+g3WhrrjYnpodCIhVKwld7dLMOv\r\nhP5sGNtLvHqaipbyBUPaBw7IEie7YaNuZlDN8SvOQwlOU2HxWpjP3F9WYmVB\r\ncWtGNj5ZAx7PeA2/1rhaDqopkH0wVJLepOZUbxgnGADwYdj6vKjbg77rqlcD\r\n9dHEseMIoII44FtJbcSFzsZwTsVx0h/4qIFCMf8xTkBCRKVlcElQga++BVFM\r\npOwtgOtxNHMO/oYiBUAOYiNJXiheDng9aJga0fH0unFyrTX7rSjADtka/PpF\r\n96gHbFOAijWh7l1oQMg3PptELymeKbsTHYnEMWvZUktTlrwouHxTJFCC5kDq\r\n7Byuiknrehxk0MW+dJK1YI8lXr43DR/BYvO8qL857uRpbMs5P4K/cYo8pJfr\r\nGYx9AjFDuIomJt4Qy40P2bXnZOI8CpUCz2IPES3SW9XAe6HkhvwqIvsf4nco\r\nvNyr/yW1NMx6wT4ZckQjnIWHuzvw/w1ga428xL5/6AiLWBwOXIv2L7h/GCo3\r\nHJe4oZm4HN13uD8NPkhGSKSDyVL+fxrs1WoozNqhnmsbig/rf3QPC7XFkWXJ\r\n4nwy5AX5oFElVN5dOQEE+//qjgxSfZ9C73A=\r\n=cKeO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"47b7bedc7727a6f9a23680edf5b42892ef94966e","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.2","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.2","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.2_1669134783871_0.16498247309814196","host":"s3://npm-registry-packages"}},"7.0.3":{"name":"streamr-client","version":"7.0.3","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.0.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"2cb3fa0ef76fd8c1a25cafb97de142f963eb3e82","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.0.3.tgz","fileCount":280,"integrity":"sha512-GWmot/UkGCo4dzhnrHBzCKBSpwvBcPvu1pf8fQlRjWjVZjVhUas+x0A1nZVvVr4bxpgDjp2QsCuJz2g/To16Ww==","signatures":[{"sig":"MEYCIQCsG+Aqo6JYKEM+MktC6CdqoAeK6gDg+cwi8HIcvU8JkgIhAI7tppHTfEl2cLNlcxA/2vHsjpxF4hcHJVtsfTnqNyfq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21756432,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjfkc2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3bA//UZ4e091P7X/FQ7ILB3bGxA1b6LI/d313sBXuXGkDx0lTSmLO\r\nA0VDhms5Q26N4nF+3hg9z3LFG23SaJe7geYmODjNeEf0QM00meYn7IGzBmlQ\r\nQ5FmiI0YJ2UlKffB4jfj8341IrkgW0B6zBIPL6Mkf36QdL3OEaOZPdaD98KY\r\nu+OhFgegTQJleoXm9TewjSMjQozAEJDJ4t6HckPW4kkgmJ4zbEChdk5uJe9C\r\n0J2/Hw+YId6NGz9BrjXyhr6+AD2mzsoD49J7BeTNL2+HoPOkFvCy14L8NhI8\r\nVbAL7Wyre4L6lAvUz3rtn/exn1DlTYmq1IsumPUdIEmoiWFRfjzEPILZPWnl\r\nBWX3FEZVZS+t/WazGpK6oHJ6omRtvcJe/mxG4LqrUHdxcU7qbeEzHAWSBMH6\r\nADI4hL9XWr+Y0xAbxvpu0pyoEzCvoKwVunO+PZyg8Wsiok52Vjzk/tE/3Vuz\r\njWlz1CAFug6uPi4wgkaaEHhJcPiHv2fylQGTCPaAdZ8Q//A/appgAN9m8fnn\r\nCPR6M/WltdVJK8AjkAjQ1N9A4aBoYxeecM3/H7QZQffW9O1tZVzUjv5s5bo4\r\n7++ou+/DVrAK5im5n37xP5AJZmj9WxyDQz4cXXwXOu8HMt+6ho9umvgpb0vp\r\n6+M49b+hsIuUyYkoLJ4c2B8YMmhHFH/r+PM=\r\n=957P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"d4a6d73b73efbd04d9f97b732f39cfbcdaffdfb0","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.0.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.0.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.0.3","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.0.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.0.3_1669220150195_0.15033050123124636","host":"s3://npm-registry-packages"}},"7.1.0":{"name":"streamr-client","version":"7.1.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@7.1.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"ca57858d7e1063b953c223e0373c99f35858d780","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.1.0.tgz","fileCount":277,"integrity":"sha512-f9OoZ/rHfuBsaWDBetvP83Yui8E1RSPRt71eLF6uY121Ai580aQQa7r+Y9oZ5gOzMXBN8mQQ/FgHqYQwoOJwMA==","signatures":[{"sig":"MEQCIHA4zMg3mbo/9/3wPOdU1cMHdVBcl8uUjnGHMTHXLZbcAiB2AOJHNK0f6EUqaWXc7ydJw4AzLMvIqBkVfmIqsXkfdw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21695796,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjgNw+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoKmg/+KQyVP3XLXSCUgj2+yfJgKS69Gi+Ncs3zpFldEKqAJ/3S/KPW\r\nEQa9ossDVK2yUX8WnFBgH5OdJioPBH7bk0sLQs6B1KFTjfzI/841MdFdW6y6\r\nNzJIRAJISyZpgeuYnKBUF6BfTyxEdTdFJuQC7tnmEIDqlniFVzc7JcL9XG81\r\nMt3jU/mqARFINoMHJQJhPg9erHq2vi3chL9mrb+g2GNVu8LykGLTgS6MD2NJ\r\nFjFWl8EfypY2pYQhr5IKT//9PgLvEBT/O9Jh7rIqtSlQCRyDAlR1dKbqyKWJ\r\nmUfkIObisPwGI6VsxLXry18DuLDHOQeb5j11SejbnTqUXxc6CY9wxzINTEZk\r\nLZNBzQdsdISYslnb3kw0e62/XVeku7h+FgyHma41w9lklQFjSjO0ngSnN+H6\r\nVC7L7OQlsSzfGOKuuvakvO28dRS0Rfmp9DpakGzlK/czAPzp1i/Po+2kgT5L\r\nQCO/SAZQP+HoXQ7oswxmTUMB9jHA6DoEDXCnqC+bAZjpjW2pWygyPdQotniX\r\nvbZuv8M7uX341Pd2xTluMNx97/DsC2PH/hgMCl4DgMk08ShIp79Hx+AatRF9\r\n7bz/7UZuBRDe4wPWpWAD/hI+7h/mqinQ8vmixc59r5iYzO0otx7knHp/PH3u\r\nY1MBmTU/rjn6ET/HzvwUW8RciVV5z/Sc5OE=\r\n=SCvb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"80719855f07ccd1f17c91e9b69825ae5f796f245","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.7.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.1.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.1.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.1.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","ethers":"^5.4.7","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^106.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.1.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.1.0_1669389374389_0.34031183916471175","host":"s3://npm-registry-packages"}},"7.2.0":{"name":"streamr-client","version":"7.2.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@7.2.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"11e3e8e176d0d760615406249b84fc0864237e8e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.2.0.tgz","fileCount":276,"integrity":"sha512-KSphHVoOP3e59M+51/iha1Oo4Hks+3h7uAgHD48zUS06JzBBr6ilHNhkXTwn2NT0novo6lc3ZJJJw1jyVyw/ZA==","signatures":[{"sig":"MEUCIQCLFCnycsKy6bXcaP0yMHzP1MOANGoV6Sqsr9hGPY2XJwIgFEGHDhusbOAU83d4Z+Hb/K5yLNjUDO0rECXmf1ojPFY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21935726,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjmcYaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp5IRAAjPmUfrq2T1TBr/PWy4VqmnbPdr8a2XcUEvbdXsk78V4nK3kG\r\nMFjUZy0PXahrAD58dUq1QcFg9M4sWIJV5eDgqKubKRv3ZGWDhmaJz+6h3zhE\r\n9Z32C4XZ3/nidKjScGZN9+V7GcOhh0TUrTzwWeCyC/pnqlyfjnU4vOKrNOY3\r\nC6kBipJhD4jbROi/wSqvS2o1yX6PjxycKn81oAh24855CYGU17TjPKRrppx1\r\nGvXIy+PgkezziBBMcxYsJQ66W22ix18VpsaRVL10LPOBQEkuVf3cVUSjudTO\r\nLHQpMB9kY4oHejSjEZCapCfC0xvYo9OaGGVl4ZR37gwfdSIgK/b8ikXoIaAJ\r\nuLIwFJ0NshprXHZ5PTj9OtwEBvVYXPt9ihKbHD1v0Hrw5KJLmuXubIv5HksP\r\n9VP51Yhl4tjZk+zkDzwhpetHriwmoj6h+B9iS4nx7+CL6YWD3UEFXb0vDtPB\r\nwq78Cabj+7okh4TkQWR7xrgFBZfJtGlhWDjYxvNEvjmkZGS+FKJGWdVEpiTU\r\ncXESKlGp0RYou1E5myDLAGZBzfHGReUdvPE757tJ40XaXY3FGJ/66dnm/qyp\r\nY1QFaSRK2GAVqJs1ic0drx4dt4JxjbLZUX9ot1OqRv7Qrhxk2tQeKZlKCRlh\r\n2C1ZkFn3+E70KJ92yD24abbTUQ7CY1l3PDU=\r\n=BalJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"43514a7b54c4d0b0d3417b5405a2e7d302d1e464","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.2.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.2.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.2.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^107.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.2.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.2.0_1671022105752_0.4970614926240484","host":"s3://npm-registry-packages"}},"7.2.1":{"name":"streamr-client","version":"7.2.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@7.2.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"8aeebb79f95d5f77dafc6b675e770e64a12870e9","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.2.1.tgz","fileCount":279,"integrity":"sha512-fD7MOK0hcQNGgyCLbl5ooXocaJsQ4S3KWCwsklmFLZrOmgj3u2VM7hf/+uSaAh8rcN8VLzvPDO8jpyw49wfoVw==","signatures":[{"sig":"MEQCIGHy1YHCFtS1UkbH4r0C5ENSMcMflI5LNGYylk1s+YJFAiBVaOr3GU9zsxnMYFJg9rZ+YiR3aopc6sv1pk9pKYmxug==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21947480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjv/V3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoRvw/+PQ/qpQcNYXx0zPzOsw8L3NLQQt6rqLM4GB8+GMxuMeufSUl2\r\nOI5XbLx3rU0XGbKlDXaSuGs7rHW8s9YKSkVV7LqvUkrdaBs7LRsifhW30Vi5\r\nE1VupB+vALzFgb/ORqm+5JOrdMLTcc62gQCQaFedmjSsCCfQofKJBXPt67g+\r\ngKktfdgz1aHXKRo65Osv2XcO1+3IcfrTt30wGS6wtPL2uw1P2Z8Uxg3MTT/z\r\n1Cxd33FffA+SK2JTlBFPX94A9Ic3T0MQT4XUyo4uorCvduG2zUZ6xYq1X+tv\r\nddtJ/kGl4jlfA3isDEdwMIID/vhwCRi2NLhWeocCnycGzzHC7F9GqtPDBm3A\r\nBPDzfCRvvIbTdCWnZfF4eoxms5uqFctbR7+RZzqysiiV7VbmH6TcZeXDUYvk\r\nbTyI7FnaUY/g6Ase+abXwD38he2jve3m1XglUXq7l5Q9p4p2RPj99tG4KkRv\r\nCPbuq//NngpWhy5NxS7LDvcmVkbg7+Yo2Jr9Lx5ZVvcfi+ZshORiNF4RhMQ5\r\nQ6RkindzUsTWb3wGPiEHZoLniZHhYL/yiBNSdcP7cyTGjV+AfaQOo9crqgDk\r\nufJ9RyTS2Dmssr84Yv1YZwro9wqSeI4ZclvXXrwl37rWb1fsHQnSuC/HMfU5\r\nNm7MrqniTpesOjWMYyRKFnYfYJzn73lUJlE=\r\n=5D2U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"798586e9825e9ea782134d41ea8b5a2d5c027600","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.2.1","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.2.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.2.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^107.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.2.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.2.1_1673524599200_0.9652257490213447","host":"s3://npm-registry-packages"}},"7.3.0-beta.0":{"name":"streamr-client","version":"7.3.0-beta.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@7.3.0-beta.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"d5f955cf385b8ddd5105bd968fb31f02ed80c6cf","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.3.0-beta.0.tgz","fileCount":282,"integrity":"sha512-unmmDQvdJsGBHfZlZ8e5Uv4SENd/LyN7XbVJKJGYPJbHHo0N6Rp1j/0tW8cRVMuFgyqE4+xWZgDkd05Wep6BUg==","signatures":[{"sig":"MEYCIQDqxGzENjjSbbD88tzlGUCGK8bsOt1/ZrbDL/vS7HQF4QIhAOPzQKHDCdfoOENkdFMtuJPyqZntKTY6uRuuf+qJrru2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32454729,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjyBOKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo2WQ/+MIGSX/tjdVFc9isKI3QNgfcfOjwPJxwRewfCCxJmAHCfgX/Z\r\nb0TeELZu3vG4KqmTHEYdGd7N/sFl4xHHOYisWkKGee3hy4SV4PLIr1EIgrOp\r\nrLv/oscS9U72+xTnUS6VhCIaIx9T+fdLTlKm0GoqCA+82w5zSXyi6/DTdTZv\r\ny+73xCHlIQHlHHtwsaLJDdDmnTrsNy1b7mCX7luS4nAoteeT3PZGVc892kej\r\n5wcPQ+ErEybpkqjfUARbnRsfjkOEpS5zVXOfoQBrMPCfKJf2+hfJtU/Zr+yt\r\nsajaSgKzD/1WGH5R6jsu1OLSkJnsJ4pFt4PO7/bwa2LS4ubSHsrzqYPVi+IS\r\nQQTF/S9kqFeyEsyoKW4X1fp9c5VxBCTKtr3K9C2Hh+B9BHhGpFMHBIyqNQfV\r\nySq1QQiMD++vZgQaS1aRIMpUGYlYOl7Kg0EZMxyNeJpIKN8tpsLv6AzWmhdi\r\nbC+liHPqc/VGP9ZlWiFzoI9ZsFMIlQIAtZzD3IJqpGfx+1Q5nxdqDeprRWys\r\nxIRU3EamhNkZaraxBxJgYUZGjIV2ReOTVgTcQUWOYZehym0qa+65dyiN0nxd\r\nDc1brAyU8uW4pipZ2/Y3p+Xx3g84rr3iDkGw0UdEyrum6Td+ka7Ijhcinzaf\r\nUMpX3FkbAHVSZD5D3L/KObeMsoJveexS8Fo=\r\n=QURq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n    - [Environments & frameworks](#environments-and-frameworks)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n    - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n### Environments and frameworks\n\n#### NodeJS\nNodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n#### Browser (Website/WebApps)\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n\n#### Browser extension\nDue to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n#### React Native\nWe are actively working on React Native compatibility but currently the Streamr JavaScript Client is not compatible with React Native. To connect, pull or push data into the Streamr Network, use the [Broker integration pattern](https://streamr.network/docs/streamr-network/connecting-applications).\n\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network/client/v7.2/index.html\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"fbfc7eb6a3c13f24a56e2f27f5cb49d354a6542e","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.3.0-beta.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.3.0-beta.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.3.0-beta.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"^2.0.40","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^107.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.3.0-beta.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.3.0-beta.0_1674056586289_0.926446954585999","host":"s3://npm-registry-packages"}},"7.3.0":{"name":"streamr-client","version":"7.3.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@7.3.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"c019af9c2dab185a8012c228fcc4d83e4c72aac2","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.3.0.tgz","fileCount":276,"integrity":"sha512-+yvvB1Sq7cKDSDq1QxqxQ0vQxFNUtA8JAIesGsagVyj/SThB/e743ypAvsjHAcIGiOlhLsNtfE+zTHJMUo9raQ==","signatures":[{"sig":"MEQCIHiRoH7TC33bPTlrVrJaIGLa+ipQoOA0LteP7xQf/+McAiB7Dg8q/u9Y60jHaMRyK2VZ0IaWNkcrbAwXFtWC+PKzMA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21947761,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjzreCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpDUg/+MDhYBpRcC9TZOpIBjNQo0ufGTIfDmS15FKaJL2BQkiEAMFJj\r\neRizbXvp4l4/Gas/74T/UuEGp40IzhT8m+WzSou3pV7yHJJ7/tW7cd3mxLCj\r\n1OmQTeZ7h0bnn41GZnlpB058DrR0UajPwBnMhkUyu85lS3mGRDlkg7TVgFKO\r\nw3NfXbp5fcRvhon85Xhd4Esio8s7rKPy57Az9CeVu7QqP9ArBCwXilVg6TEE\r\nHFqBjwitY15FfNOBYBJchgIHIXy9cPGFoMGZh3VWaxmQ58Afx1QmE1iPTOR1\r\nigTo1BSgIbeiLDdbk9IP9ST537oKCzGBDk+14P9HE9ew4t2aGawA7KKm43/t\r\nkdhPB28wKQxhc7j4wxpbdpmo0wH0+iZXPIoDickPhMB5AURbp2cNfX6AaRP2\r\nc4Lb8d+kI02xsAVpTMvYWwnikBozHbPyVDebUEUsP8MwzNUFDF1mMrCIeLWe\r\nIzgBcKA2U103rglDg/FC8YF+6STvL8P3jBT+gCdj5c4xNCUQC/XhAVYhvLkP\r\nslc8ShA0acctsQCsw4cpHJRrYy0LK8LfAJjwmkoTsetL7kGZIhxs+E3RPEuy\r\nstR6oMGW5nrQUaJVjcvF4HlZJFjjbzL5KvB8IBb/JA+nAAxKBaR/+JjEjlTn\r\nK57lXRf6ba0HTH5fl3Pd+N28QXvqzcQpwFA=\r\n=u6PU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"0ab907f64b71ec01ab4b4306ec2a660d259134ff","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.3.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.3.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.3.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^108.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.3.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.3.0_1674491778404_0.49890858618176903","host":"s3://npm-registry-packages"}},"7.4.0-beta.0":{"name":"streamr-client","version":"7.4.0-beta.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@7.4.0-beta.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"efed540ae055a9150517f407549ccf91910395d7","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.4.0-beta.0.tgz","fileCount":282,"integrity":"sha512-/EZSmffqI4ulqM1EPfffnUbsiQeMTTgXlo34SmOAbS2WymcMnPFoxrH2sAoMetjkHIi1ud9VBpavX1p+VmwyHA==","signatures":[{"sig":"MEQCIGrBs6qMPDnLeMZwSJHGRZxOt/7ngvOVlslsbWgQoskIAiAyDyuNHHMrkxoYn6sAgm5aT2vZFIuJw+Gf+Q+JrJX/Tg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33570120,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj07LlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmomORAAnygFZHdZRklEdFyVZSdzaEDTI7nqW58+TfnL7hHdBwrTRc4x\r\nfG57PTLZz+AbhiIgGjYuXqHz8qi/YWJt9/Xa4H3vHySLvcOqevC6lAfGhBr/\r\nrnD5Jmf1eGxkpN84r7wKFpRP38QiI6dZtzuIfP09bR61YkSZdoDoWped8RqM\r\noZFT/U1jOAm1wrJYWMGZSAlD02vHsPbutzKcQuOGh9m72e9yIFoPBHBpTO52\r\nSPtGRGfxUo4287BakqDHg3xHQ8NAsTBzZV3xsktNIczZEZsERt232VE/fkYz\r\n3xHCFMsAdHKLrNYu7nspVQhSesTX45acS3r6PfGQfAVOjLrqjURERvnM5Waw\r\nX3P/CFeGhLbyhQDOrvgp8hqfGzoLXdDAHu0tq1JDTUk7ukbhy7NL21YuzZlr\r\nhTHxM6uXc7vdxQ/00cgDZfRsBhaJjopmPKjyXi8K3rnvLtrXcJ3d+E4J1Lx6\r\nAAZLUBaODBiUKJ1F0Tqoc8pwNXLuefPeOsqHYSl/uQAWfMHc0nJFOS2SzJpA\r\n5ZsnH+lCzZ0M/8Ba3JK1hBH1saYzflCvzuKdVVgyG7H9m/6yurv9j2AIsGA4\r\nzigNdSklqucPqFtCRn8ecPwtU0CHav9jgnDOrU0MoWc39ZBr1Rfa680QI7cO\r\nv0dXN77aKRQoPWme5UnbV5phwKME71FJVks=\r\n=rSnU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n    - [Environments & frameworks](#environments-and-frameworks)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n    - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n### Environments and frameworks\n\n#### NodeJS\nNodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n#### Browser (Website/WebApps)\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n\n#### Browser extension\nDue to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n#### React Native\nWe are actively working on React Native compatibility but currently the Streamr JavaScript Client is not compatible with React Native. To connect, pull or push data into the Streamr Network, use the [Broker integration pattern](https://streamr.network/docs/streamr-network/connecting-applications).\n\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network/client/v7.2/index.html\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"e17972b52e380f553ea3c2e069937c0e52f2b14f","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"7.4.0-beta.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"7.4.0-beta.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"7.4.0-beta.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"^2.0.66","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^108.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"7.4.0-beta.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.4.0-beta.0_1674818276810_0.9021200725219538","host":"s3://npm-registry-packages"}},"7.4.0-beta.1":{"name":"streamr-client","version":"7.4.0-beta.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@7.4.0-beta.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"155c0ff5b040cfce15aecd24707fc82a3d753d4e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-7.4.0-beta.1.tgz","fileCount":282,"integrity":"sha512-ptvOQhyU/taVO93FxdvnwbHlaNoedXOqeXupsHkX2o0ssIl4HamIYetk52Y+/eSMLU9/0gCJn3AjLhabE5yvVw==","signatures":[{"sig":"MEQCIEhEGKZynh9UAOJCVzjKlGU5urN48Z979jFFQzZ4KXJzAiB257B7DhNllqbPWYI4o6f4N1pbmJneVcNtAbbIcgVWAg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33582850,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj19mKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZaw//Rl7HyCQ3f27AjtQjJ/oDKEXbI3gVmbR1tZQe4R/5/8n441/N\r\nyRT9wn5zxA6ReWhCLgndRWHCqJg+667ffUnYFjNEo0t0Z0nWtqGST1EJmKQZ\r\nPcY13e5HLbyXhYjNQMaUlOwlWHygT7/BZ2OeNThAX4XWl7T70obu3Q0jX8W6\r\nM5EvhfXEayvlIpL7oW0vPeyV5sAuDNG/hPsv02i780/l0dpNLDqRXcoGTNy1\r\noQeLhWPDagFjHKSEYVGLXgj1JPGN8kV/4zPjOXKS4AavXBUlg8P9trjfNT4b\r\nvjSo4RTBREsOgA56HphrYDdGVLHEIbwelUKQAbZBjANpScunu+QA2x7JPTg/\r\ngJaC2S+da0vW24cDLQEoFTf8UlBgyOVmbkKYX2RHQd7thZleGPXWJk2ayEbY\r\nqe9zl1R6pozrgFWkQJI+xoUH5DXH+gbiRZZ0mxkheAUqEPP8bzjY3/oq+b69\r\nI/qOW5Z6o4zsDaFo+3Nii+qobiH1uvsho8QIksKJkLGmDP7vap/JWktNFF2K\r\n3q98nj6gLHIwtw67Ad66dFdSRQj85s1gtK7nZojHlngLxVNdRC3+rajWdt7k\r\nwo3iKoUALpeev20Pd5eFeb6ikcT9p9Dl6hGLozHoBg+ApG+zqcDbjah57utl\r\niizl3IclmEDznMu85mn4pBb15D4qmo9J/zI=\r\n=rjNj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n    - [Environments & frameworks](#environments-and-frameworks)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n    - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n### Environments and frameworks\n\n#### NodeJS\nNodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n#### Browser (Website/WebApps)\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n\n#### Browser extension\nDue to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n#### React Native\nWe are actively working on React Native compatibility but currently the Streamr JavaScript Client is not compatible with React Native. To connect, pull or push data into the Streamr Network, use the [Broker integration pattern](https://streamr.network/docs/streamr-network/connecting-applications).\n\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network/client/v7.3/index.html\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThere are two optional configuration options related to encryption keys:\n- `decryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `decryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n```js\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n\n// Open publish proxy to multiple nodes on stream\nawait publishingClient.openProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n\n// Remove publish proxy to multiple nodes on stream\nawait publishingClient.closeProxyConnections(stream, ['0x11111...', '0x22222...'], ProxyDirection.SUBSCRIBE)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"2e833728936936d91fe6de25dc3343da99931761","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"v7.4.0-beta.1","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"v7.4.0-beta.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"v7.4.0-beta.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.16","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^108.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"v7.4.0-beta.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_7.4.0-beta.1_1675090314118_0.3061666536969785","host":"s3://npm-registry-packages"}},"5.6.0":{"name":"streamr-client","version":"5.6.0","author":{"name":"Streamr"},"license":"Apache-2.0","_id":"streamr-client@5.6.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/streamr-client#readme","bugs":{"url":"https://github.com/streamr-dev/streamr-client/issues"},"dist":{"shasum":"da61e6b110f8130216f24e1386ad4884a5530d60","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-5.6.0.tgz","fileCount":184,"integrity":"sha512-bcvQfPwJsO+fkTQr7gHGqArr4aVYRKAkCCAjlFTVK4C8RD0sCW8Y0Ffazq5tzC//Jrd3tkgk5cZjPylla3JE8Q==","signatures":[{"sig":"MEYCIQDVRf8fk9isZXWW5Tp610lDa4r284/K8lRPI2afFtrFpAIhAL+c5cbmUE9WwtoIFfBx3jIcpLE4kROsLjnWVb0ZRMRO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14005917,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj6mgNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmplfxAAnmrint/NJogmLzlePWTm5JFwW7vs0IebhPlyzfD159ilhB4d\r\nDngpUU2kZA6O9o/NLQtnMu3aaUTf9HmMa6zbt4zO94xrQn/08wnT+o8OlwgP\r\nRdtOpInXV4qV74VdeRhv8JDG541SqYW5pIMB3Zt6GbxPYHtzn1G3TPw5ZRj3\r\n7OsLJrdxzNEJFa7VbX8oOC9OtLtdoanQzJpiMGaSFRSS8+moGmrC768kyISh\r\nL6in1ORFSn2fhW5xCYtWBDKaL2q4f8YIadL8X3aT+XkG0uBiiG3fFTpSvmTA\r\nmGIwtm9MVKvHyL2ou8Vp32v1lEGoecUxEDNbwuczSgX0voX2bp8sG/TLM5KI\r\n0i5GdR6JJCG+FLOL9xMAg1Cor9DGRTo2vay49gBbmeaNxs2yl79+W+LiXhXq\r\nm+w4tK57M4L27fkalXrMeJ53vqVkYvmEnO2BHZnetm42KJAndhJzBS9nF9j3\r\nQx1v5vAkUw1LtJuxJspV0I7oiFnZvjzjLVxhdQc6S77qf/luAECqRQRpxZAx\r\n42wZpfHuMWCfFvTJpOguOgA9WwO4AfixhMKagoK6Q2SEqOxcxGTOeg9gQufA\r\nuGUoR4KsBfrX/eUTc6LENvAI8J+xQ8KoZ6Y23P3mUyWrIfJo9G8hJI6Qgtj0\r\n9LMGZKtouedSoy5rtUo4UDl923Ju9u03Trg=\r\n=XAIo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/index-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header-img.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![Build Status](https://img.shields.io/github/workflow/status/streamr-dev/streamr-client-javascript/Test%20Build/master)\n[![GitHub release](https://img.shields.io/github/release/streamr-dev/streamr-client-javascript.svg?style=flat)](https://github.com/streamr-dev/streamr-client-javascript/releases/)\n[![GitHub stars](https://img.shields.io/github/stars/streamr-dev/streamr-client-javascript.svg?style=flat&label=Star&maxAge=2592000)](https://github.com/streamr-dev/streamr-client-javascript/)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nBy using this client, you can easily interact with the [Streamr](https://streamr.network) API from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). You can, for example, subscribe to real-time data in streams, produce new data to streams, and create new streams. The client uses websockets for producing and consuming messages to/from streams. It should work in all modern browsers.\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\n\n----\n\n## TOC\n\n[Installation](#installation) · [Usage](#usage) · [API Docs](#API-docs) · [Client options](#client-options) · [Authentication](#authentication-options) · [Managing subscriptions](#managing-subscriptions) · [Stream API](#stream-api) · [Subscription options](#subscription-options) · [Data Unions](#data-unions) · [Utility functions](#utility-functions) · [Events](#events) · [Stream Partitioning](#stream-partitioning) · [Logging](#logging) · [NPM Publishing](#publishing-latest)\n\n\n## Installation\n\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nNode v14 or higher is recommended if you intend to use the client in a Node environment. For example, inside a script.\n\n## Usage\n\nHere are some quick examples. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for more detailed documentation.\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\n### Creating a StreamrClient instance\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nWhen using Node.js remember to import the library with:\n\n```js\nimport { StreamrClient } from 'streamr-client';\n```\n\n### Subscribing to real-time events in a stream\n\n```js\nconst sub = await client.subscribe({\n    stream: 'streamId',\n    partition: 0, // Optional, defaults to zero. Use for partitioned streams to select partition.\n    // optional resend options here\n}, (message, metadata) => {\n    // This is the message handler which gets called for every incoming message in the stream.\n    // Do something with the message here!\n})\n```\n\n### Resending historical data\n\n```js\nconst sub = await client.resend({\n    stream: 'streamId',\n    resend: {\n        last: 5,\n    },\n}, (message) => {\n    // This is the message handler which gets called for every received message in the stream.\n    // Do something with the message here!\n})\n```\n\nSee \"Subscription options\" for resend options\n\n### Programmatically creating a stream\n\n```js\nconst stream = await client.createStream({\n    id: '/foo/bar', // or 0x1234567890123456789012345678901234567890/foo/bar or mydomain.eth/foo/bar\n})\nconsole.log(`Stream ${stream.id} has been created!`)\n\n// Optional: to enable historical data resends, add the stream to a storage node\nawait stream.addToStorageNode(StorageNode.STREAMR_GERMANY)\n\n// Do something with the stream, for example call stream.publish(message)\n```\n\n### Publishing data points to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait client.publish('my-stream-id', msg)\n\n// The first argument can also be the stream object\nawait client.publish(stream, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait client.publish('my-stream-id', msg, new Date(54365472))\n\n// Publish with a specific timestamp in ms\nawait client.publish('my-stream-id', msg, 54365472)\n\n// Publish with a specific timestamp as a ISO8601 string\nawait client.publish('my-stream-id', msg, '2019-01-01T00:00:00.123Z')\n\n// Publish with a specific partition key (read more about partitioning further down this readme)\nawait client.publish('my-stream-id', msg, Date.now(), 'my-partition-key')\n\n// For convenience, stream.publish(...) equals client.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n----\n\n## API Docs\n\nThe [API docs](https://streamr-dev.github.io/streamr-client-javascript/) are automatically generated from the TypeScript source code. They can also be rebuilt locally via:\n\n```\nnpm run docs\n```\n\n## Client options\n\n| Option                   | Default value                    | Description                                                                                                                                                                                                                                                                                                                             |\n| :----------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| url                      | wss://streamr.network/api/v1/ws  | Address of the Streamr websocket endpoint to connect to.                                                                                                                                                                                                                                                                                |\n| restUrl                  | <https://streamr.network/api/v1> | Base URL of the Streamr REST API.                                                                                                                                                                                                                                                                                                       |\n| auth                     | {}                               | Object that can contain different information to authenticate. More details below.                                                                                                                                                                                                                                                      |\n| publishWithSignature     | 'auto'                           | Determines if data points published to streams are signed or not. Possible values are: 'auto', 'always' and 'never'. Signing requires `auth.privateKey` or `auth.ethereum`.  'auto' will sign only if one of them is set. 'always' will throw an exception if none of them is set.                                                      |\n| verifySignatures         | 'auto'                           | Determines under which conditions signed and unsigned data points are accepted or rejected. 'always' accepts only signed and verified data points. 'never' accepts all data points. 'auto' verifies all signed data points before accepting them and accepts unsigned data points only for streams not supposed to contain signed data. |\n| autoConnect              | true                             | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.                                                                                                                                                                                          |\n| autoDisconnect           | true                             | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.                                                                                                                                        |\n| orderMessages            | true                             | If set to `true`, the subscriber handles messages in the correct order, requests missing messages and drops duplicates. Otherwise, the subscriber processes messages as they arrive without any check.                                                                                                                                  |\n| maxPublishQueueSize      | 10000                            | Only in effect when `autoConnect = true`. Controls the maximum number of messages to retain in internal queue when client has disconnected and is reconnecting to Streamr.                                                                                                                                                              |\n| publisherGroupKeys       | {}                               | Object defining the group key as a hex string used to encrypt for each stream id.                                                                                                                                                                                                                                                       |\n| publisherStoreKeyHistory | true                             | If `true`, the client will locally store every key used to encrypt messages at some point. If set to `false`, the client will not be able to answer subscribers asking for historical keys during resend requests.                                                                                                                      |\n| subscriberGroupKeys      | {}                               | Object defining, for each stream id, an object containing the group key used to decrypt for each publisher id. Not needed if `keyExchange` is defined.                                                                                                                                                                                  |\n| keyExchange              | {}                               | Defines RSA key pair to use for group key exchange. Can define `publicKey` and `privateKey` fields as strings in the PEM format, or stay empty to generate a key pair automatically. Can be set to `null` if no key exchange is required.                                                                                               |\n\n## Authentication options\n\nNote: **Authenticating with an API key has been deprecated. Cryptographic keys/wallets is the only supported authentication method.**\n\nIf you don't have an Ethereum account you can use the utility function `StreamrClient.generateEthereumAccount()`, which returns the address and private key of a fresh Ethereum account.\n\nAuthenticating with Ethereum also automatically creates an associated Streamr user, even if it doesn't already exist. Under the hood, the client will cryptographically sign a challenge to authenticate you as a Streamr user:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider:\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nAuthenticating with a pre-existing session token (used internally by the Streamr app):\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        sessionToken: 'session-token'\n    }\n})\n```\n\nTo extract the session token from an authenticated client:\n\n```js\nconst bearerToken = await client.session.getSessionToken()\n```\n\nThen for example, \n```js\n    axios({\n        headers: {\n            Authorization: `Bearer ${bearerToken}`,\n        },\n        ...\n    )}\n```\n\nNote, session tokens expire after four hours and may need to be refreshed.\n\n## Connecting\n\nBy default the client will automatically connect and disconnect as needed, ideally you should not need to manage connection state explicitly.\nSpecifically, it will automatically connect when you publish or subscribe, and automatically disconnect once all subscriptions are removed and no\nmessages were recently published. This behaviour can be disabled using the `autoConnect` & `autoDisconnect` options when creating a `new\nStreamrClient`. Explicit calls to either `connect()` or `disconnect()` will disable all `autoConnect` & `autoDisconnect` functionality, but they can\nbe re-enabled by calling `enableAutoConnect()` or `enableAutoDisconnect()`.\n\nCalls that need a connection, such as `publish` or `subscribe` will fail with an error if you are disconnected and autoConnect is disabled.\n\n| Name                                | Description                                                                                                                                                                                         |\n| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| connect()                           | Safely connects if not connected. Returns a promise. Resolves immediately if already connected. Only rejects if an error occurs during connection.                                                  |\n| disconnect()                        | Safely disconnects if not already disconnected, clearing all subscriptions. Returns a Promise.  Resolves immediately if already disconnected. Only rejects if an error occurs during disconnection. |\n| enableAutoConnect(enable = true)    | Enables autoConnect if it wasn't already enabled. Does not connect immediately. Use `enableAutoConnect(false)` to disable autoConnect.                                                              |\n| enableAutoDisconnect(enable = true) | Enables autoDisconnect if it wasn't already enabled. Does not disconnect immediately. Use `enableAutoConnect(false)` to disable autoDisconnect.                                                     |\n\n```js\nconst client = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    },\n    autoConnect: false,\n    autoDisconnect: false,\n})\n\nawait client.connect()\n```\n\n## Managing subscriptions\n\n| Name                         | Description                                                                                                                                                                     |\n| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a Promise resolving a `Subscription` object. |\n| unsubscribe(Subscription)    | Unsubscribes the given `Subscription`. Returns a promise.                                                                                                                       |\n| unsubscribeAll(`streamId`)   | Unsubscribes all `Subscriptions` for `streamId`. Returns a promise.                                                                                                             |\n| getSubscriptions() | Returns a list of all active `Subscriptions` on this client. Returns a promise.                                                                                                            |\n\n### Message handler callback\n\nThe second argument to `client.subscribe(options, callback)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:\n\n| Argument      | Description                                                                                                                                                                                                                      |\n| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| payload       | A JS object containing the message payload itself                                                                                                                                                                                |\n| streamMessage | The whole [StreamMessage](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/message_layer/StreamMessage.js) object containing various metadata, for example `streamMessage.getTimestamp()` etc. |\n\n```js\nconst sub = await client.subscribe({\n    streamId: 'my-stream-id',\n}, (payload, streamMessage) => {\n    console.log({\n        payload, streamMessage\n    })\n})\n\n```\n\n### Subscription Options\n\nNote that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.\n\n| Name      | Description                                                                        |\n| :-------- | :--------------------------------------------------------------------------------- |\n| stream    | Stream id to subscribe to                                                          |\n| partition | Partition number to subscribe to. Defaults to partition 0.                         |\n| resend    | Object defining the resend options. Below are examples of its contents.            |\n| groupKeys | Object defining the group key as a hex string for each publisher id of the stream. |\n\n```js\n// Resend N most recent messages\nconst sub1 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n\n// Resend from a specific message reference up to the newest message\nconst sub2 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n\n// Resend a limited range of messages\nconst sub3 = await client.subscribe({\n    streamId: 'my-stream-id',\n    resend: {\n        from: {\n            timestamp: 12345,\n            sequenceNumber: 0, // optional\n        },\n        to: {\n            timestamp: 54321,\n            sequenceNumber: 0, // optional\n        },\n        publisher: 'publisherId', // optional\n        msgChainId: 'msgChainId', // optional\n    }\n}, onMessage)\n```\n\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await client.subscribe(options)\nsub.on('resent', () => {\n    console.log('All caught up and received all requested historical messages! Now switching to real time!')\n})\n```\n\n## Stream API\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                                | Description                                                                                                                                          |\n| :-------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |\n| getStream(streamId)                                 | Fetches a stream object from the API.                                                                                                                |\n| listStreams(query)                                  | Fetches an array of stream objects from the API. For the query params, consult the [API docs](https://api-explorer.streamr.com).                     |\n| getStreamByName(name)                               | Fetches a stream which exactly matches the given name.                                                                                               |\n| createStream(\\[properties])                         | Creates a stream with the given properties. For more information on the stream properties, consult the [API docs](https://api-explorer.streamr.com). If you specify `id`, it can be a full streamId or a path (e.g. `/foo/bar` will create a stream with id `<your-ethereum-address>/foo/bar` if you have authenticated with a private key)|\n| getOrCreateStream(properties)                       | Gets a stream with the id or name given in `properties`, or creates it if one is not found.                                                          |\n| publish(streamId, message, timestamp, partitionKey) | Publishes a new message to the given stream.                                                                                                         |\n\n### Stream object\n\nAll the below functions return a Promise which gets resolved with the result.\n\n| Name                                      | Description                                                                                                                                                                                                                                                                   |\n| :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| update()                                  | Updates the properties of this stream object by sending them to the API.                                                                                                                                                                                                      |\n| delete()                                  | Deletes this stream.                                                                                                                                                                                                                                                          |\n| getPermissions()                          | Returns the list of permissions for this stream.                                                                                                                                                                                                                              |\n| hasPermission(operation, user)            | Returns a permission object, or null if no such permission was found. Valid `operation` values for streams are: stream_get, stream_edit, stream_delete, stream_publish, stream_subscribe, and stream_share. `user` is the username of a user, or null for public permissions. |\n| grantPermission(operation, user)          | Grants the permission to do `operation` to `user`, which are defined as above.                                                                                                                                                                                                |\n| revokePermission(permissionId)            | Revokes a permission identified by its `id`.                                                                                                                                                                                                                                  |\n| detectFields()                            | Updates the stream field config (schema) to match the latest data point in the stream.                                                                                                                                                                                        |\n| publish(message, timestamp, partitionKey) | Publishes a new message to this stream.                                                                                                                                                                                                                                       |\n\n## Data Unions\n\nThis library provides functions for working with Data Unions. Please see the [API Docs](https://streamr-dev.github.io/streamr-client-javascript/) for auto-generated documentation on each Data Union endpoint.\n\nTo deploy a new DataUnion with default [deployment options](#deployment-options):\n```js\nconst dataUnion = await client.deployDataUnion()\n```\n\nTo get an existing (previously deployed) `DataUnion` instance:\n```js\nconst dataUnion = client.getDataUnion(dataUnionAddress)\n```\n\nOr to verify untrusted (e.g. user) input, use:\n```js\nconst dataUnion = await client.safeGetDataUnion(dataUnionAddress)\n```\n\n<!-- This stuff REALLY isn't for those who use our infrastructure, neither DU admins nor DU client devs. It's only relevant if you're setting up your own sidechain.\nThese DataUnion-specific options can be given to `new StreamrClient` options:\n\n| Property                            | Default                                                | Description                                                                                |\n| :---------------------------------- | :----------------------------------------------------- | :----------------------------------------------------------------------------------------- |\n| dataUnion.minimumWithdrawTokenWei   | 1000000                                                | Threshold value set in AMB configs, smallest token amount that can pass over the bridge    |\n| dataUnion.payForTransport           | true                                                   | true = client does the transport as self-service and pays the mainnet gas costs            |\n|                                     |                                                        | false = someone else pays for the gas when transporting the withdraw tx to mainnet         |\n-->\n\n### Admin Functions\n\nAdmin functions require xDai tokens on the xDai network. To get xDai you can either use a [faucet](https://www.xdaichain.com/for-users/get-xdai-tokens/xdai-faucet) or you can reach out on the [Streamr Discord #dev channel](https://discord.gg/gZAm8P7hK8).\n\nAdding members using admin functions is not at feature parity with the member function `join`. The newly added member will not be granted publish permissions to the streams inside the Data Union. This will need to be done manually using, `streamr.grantPermission(stream_publish, user)`. Similarly, after removing a member using the admin function `removeMembers`, the publish permissions will need to be removed in a secondary step using `revokePermission(permissionId)`.\n\n| Name                              | Returns             | Description                                                    |\n| :-------------------------------- | :------------------ | :------------------------------------------------------------- |\n| createSecret(\\[name])             | string              | Create a secret for a Data Union                               |\n| addMembers(memberAddressList)     | Transaction receipt | Add members                                                    |\n| removeMembers(memberAddressList)  | Transaction receipt | Remove members from Data Union                                 |\n| setAdminFee(newFeeFraction[, ethersOptions]) `**`                                                     | Transaction receipt     | `newFeeFraction` is a `Number` between 0.0 and 1.0 (inclusive) |\n| withdrawAllToMember(memberAddress\\[, [options](#withdraw-options)\\])                              | Transaction receipt `*` | Send all withdrawable earnings to the member's address |\n| withdrawAllToSigned(memberAddress, recipientAddress, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |\n| withdrawAmountToSigned(memberAddress, recipientAddress, amountTokenWei, signature\\[, [options](#withdraw-options)\\]) | Transaction receipt `*` | Send some of the withdrawable earnings to the address signed off by the member |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.<br>\n`**` `ethersOptions` that `setAdminFee` takes can be found as [\"overrides\" documented in docs.ethers.io](https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend).\n\nHere's how to deploy a Data Union contract with 30% Admin fee and add some members:\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = await client.deployDataUnion({\n    adminFee: 0.3,\n})\nconst receipt = await dataUnion.addMembers([\n    \"0x1234567890123456789012345678901234567890\",\n    \"0x1234567890123456789012345678901234567891\",\n    \"0x1234567890123456789012345678901234567892\",\n])\n```\n\n### Member functions\n\n| Name                                                                  | Returns                   | Description                                                                 |\n| :-------------------------------------------------------------------- | :------------------------ | :-------------------------------------------------------------------------- |\n| join(\\[secret])                                                       | JoinRequest               | Join the Data Union (if a valid secret is given, the promise waits until the automatic join request has been processed)  |\n| part()                                                                | Transaction receipt       | Leave the Data Union\n| isMember(memberAddress)                                               | boolean                   |                                                                             |\n| withdrawAll(\\[[options](#withdraw-options)\\])                         | Transaction receipt `*`   | Withdraw funds from Data Union                                              |\n| withdrawAllTo(recipientAddress\\[, [options](#withdraw-options)\\])     | Transaction receipt `*`   | Donate/move your earnings to recipientAddress instead of your memberAddress |\n| signWithdrawAllTo(recipientAddress)                                   | Signature (string)        | Signature that can be used to withdraw all available tokens to given recipientAddress        |\n| signWithdrawAmountTo(recipientAddress, amountTokenWei)                | Signature (string)        | Signature that can be used to withdraw a specific amount of tokens to given recipientAddress |\n| transportMessage(messageHash[, pollingIntervalMs[, retryTimeoutMs]])  | Transaction receipt       | Send the mainnet transaction to withdraw tokens from the sidechain |\n\n`*` The return value type may vary depending on [the given options](#withdraw-options) that describe the use case.\n\nHere's an example on how to sign off on a withdraw to (any) recipientAddress (NOTE: this requires no gas!)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst signature = await dataUnion.signWithdrawAllTo(recipientAddress)\n```\n\nLater, anyone (e.g. Data Union admin) can send that withdraw transaction to the blockchain (and pay for the gas)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst client = new StreamrClient({\n    auth: { privateKey },\n})\n\nconst dataUnion = client.getDataUnion(dataUnionAddress)\nconst receipt = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature)\n```\n\nThe `messageHash` argument to `transportMessage` will come from the withdraw function with the specific options. The following is equivalent to the above withdraw line:\n```js\nconst messageHash = await dataUnion.withdrawAllToSigned(memberAddress, recipientAddress, signature, {\n    payForTransport: false,\n    waitUntilTransportIsComplete: false,\n}) // only pay for sidechain gas\nconst receipt = await dataUnion.transportMessage(messageHash) // only pay for mainnet gas\n```\n\n### Query functions\n\nThese are available for everyone and anyone, to query publicly available info from a Data Union:\n\n| Name                                                       | Returns                                        | Description                             |\n| :--------------------------------------------------------- | :--------------------------------------------- | :-------------------------------------- |\n| getStats()                                                 | {activeMemberCount, totalEarnings, ...}        | Get Data Union's statistics             |\n| getMemberStats(memberAddress)                              | {earnings, proof, ...}                         | Get member's stats                      |\n| getWithdrawableEarnings(memberAddress)                     | `BigNumber` withdrawable DATA tokens in the DU |                                         |\n| getAdminFee()                                              | `Number` between 0.0 and 1.0 (inclusive)       | Admin's cut from revenues               |\n| getAdminAddress()                                          | Ethereum address                               | Data union admin's address              |\n| getVersion()                                               | `0`, `1` or `2`                                | `0` if the contract is not a data union |\n\nHere's an example how to get a member's withdrawable token balance (in \"wei\", where 1 DATA = 10^18 wei)\n\n```js\nimport { StreamrClient } from 'streamr-client'\n\nconst dataUnion = new StreamrClient().getDataUnion(dataUnionAddress)\nconst withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)\n```\n\n### Withdraw options\n\nThe functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned`, `withdrawAmountToSigned` all can take an extra \"options\" argument. It's an object that can contain the following parameters:\n\n| Name              | Default               | Description                                                                               |\n| :---------------- | :-------------------- | :--------------------------------------------------------------------------------------   |\n| sendToMainnet     | true                  | Whether to send the withdrawn DATA tokens to mainnet address (or sidechain address)       |\n| payForTransport   | true                  | Whether to pay for the withdraw transaction signature transport to mainnet over the bridge|\n| waitUntilTransportIsComplete | true       | Whether to wait until the withdrawn DATA tokens are visible in mainnet                    |\n| pollingIntervalMs | 1000 (1&nbsp;second)  | How often requests are sent to find out if the withdraw has completed                     |\n| retryTimeoutMs    | 60000 (1&nbsp;minute) | When to give up when waiting for the withdraw to complete                                 |\n| gasPrice          | network estimate      | Ethereum Mainnet transaction gas price to use when transporting tokens over the bridge    | \n\nThese withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low),\nbut a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.\n\nThe return values from the withdraw functions also depend on the options.\n\nIf `sendToMainnet: false`, other options don't apply at all, and **sidechain transaction receipt** is returned as soon as the withdraw transaction is done. This should be fairly quick in the sidechain.\n\nThe use cases corresponding to the different combinations of the boolean flags:\n\n| `transport` | `wait`  | Returns | Effect |\n| :---------- | :------ | :------ | :----- |\n| `true`      | `true`  | Transaction receipt | *(default)* Self-service bridge to mainnet, client pays for mainnet gas |\n| `true`      | `false` | Transaction receipt | Self-service bridge to mainnet (but **skip** the wait that double-checks the withdraw succeeded and tokens arrived to destination) |\n| `false`     | `true`  | `null`              | Someone else pays for the mainnet gas automatically, e.g. the bridge operator (in this case the transaction receipt can't be returned) |\n| `false`     | `false` | AMB message hash    | Someone else pays for the mainnet gas, but we need to give them the message hash first | \n\n### Deployment options\n\n`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:\n\n| Name                      | Type      | Default               | Description                                                                           |\n| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |\n| owner                     | Address   |`*`you                 | Owner / admin of the newly created Data Union                                         |\n| joinPartAgents            | Address[] |`*`you, Streamr Core   | Able to add and remove members to/from the Data Union                                 |\n| dataUnionName             | string    | Generated             | NOT stored anywhere, only used for address derivation                                 |\n| adminFee                  | number    | 0 (no fee)            | Must be between 0...1 (inclusive)                                                     |\n| sidechainPollingIntervalMs| number    | 1000 (1&nbsp;second)  | How often requests are sent to find out if the deployment has completed               |\n| sidechainRetryTimeoutMs   | number    | 60000 (1&nbsp;minute) | When to give up when waiting for the deployment to complete                           |\n| confirmations             | number    | 1                     | Blocks to wait after Data Union mainnet contract deployment to consider it final      |\n| gasPrice                  | BigNumber | network estimate      | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract      |\n\n`*`you here means the address of the authenticated StreamrClient\n(that corresponds to the `auth.privateKey` given in constructor)\n\nStreamr Core is added as a `joinPartAgent` by default\nso that joining with secret works using the [member function](#member-functions) `join`.\nIf you don't plan to use `join` for \"self-service joining\",\nyou can leave out Streamr Core agent by calling `deployDataUnion`\ne.g. with your own address as the sole joinPartAgent:\n```\nconst dataUnion = await client.deployDataUnion({\n    joinPartAgents: [yourAddress],\n    adminFee,\n})\n```\n\n`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.\nData Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means\na Data Union deployed by a particular address with particular \"name\" will have a predictable address.\n            \n## Utility functions\n\n| Name                                    | Returns                 |   Description    |\n| :-------------------------------------- | :---------------------- | :--------------- |\n| `*` generateEthereumAccount()           | `{address, privatekey}` | Generates a random Ethereum account  |\n| getTokenBalance(address)                | `BigNumber`             | Mainnet DATA token balance |\n| getSidechainTokenBalance(address)       | `BigNumber`             | Sidechain DATA token balance |\n\n`*` The static function `StreamrClient.generateEthereumAccount()` generates a new\nEthereum private key and returns an object with fields `address` and `privateKey`.\nNote that this private key can be used to authenticate to the Streamr API\nby passing it in the authentication options, as described earlier in this document.\n\n## Events\n\nThe client and the subscriptions can fire events as detailed below.\nYou can bind to them using `on`.\n\n| Name                                | Description                                                                              |\n| :---------------------------------- | :--------------------------------------------------------------------------------------- |\n| on(eventName, function)             | Binds a `function` to an event called `eventName`                                        |\n| once(eventName, function)           | Binds a `function` to an event called `eventName`. It gets called once and then removed. |\n| removeListener(eventName, function) | Unbinds the `function` from events called `eventName`                                    |\n\n### Events on the StreamrClient instance\n\n| Name         | Handler Arguments | Description                                                      |\n| :----------- | :---------------- | :--------------------------------------------------------------- |\n| connected    |                   | Fired when the client has connected (or reconnected).            |\n| disconnected |                   | Fired when the client has disconnected (or paused).              |\n| error        | Error             | Fired when the client encounters an error e.g. connection issues |\n\n```js\n// The StreamrClient emits various events\nclient.on('connected', () => {\n    // note no need to wait for this before doing work,\n    // with autoconnect enabled the client will happily establish a connection for you as required.\n    console.log('Yeah, we are connected now!')\n})\n```\n\n### Events on the Subscription object\n\n| Name         | Handler Arguments                                                                                                                                                         | Description                                                                                         |\n| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------- |\n| unsubscribed |                                                                                                                                                                           | Fired when an unsubscription is acknowledged by the server.                                         |\n| resent       | [ResendResponseResent](https://github.com/streamr-dev/streamr-client-protocol-js/blob/master/src/protocol/control_layer/resend_response_resent/ResendResponseResentV1.js) | Fired after `resending` when the subscription has finished resending and message has been processed |\n| error        | Error object                                                                                                                                                              | Reports errors, for example problems with message content                                           |\n\n## Stream Partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any positive number (1-100 is reasonable). An example of creating a partitioned stream using the JS client:\n\n```js\nconst stream = await client.createStream({\n    name: 'My partitioned stream',\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.partitions} partitions.`)\n```\n\n### Publishing to partitioned streams\n\nIn most use cases, a user wants related events (e.g. events from a particular device) to be assigned to the same partition, so that the events retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nThe library allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait client.publish('my-stream-id', msg, Date.now(), msg.vehicleId)\n\n// or, equivalently\nawait stream.publish(msg, Date.now(), msg.vehicleId)\n```\n\n### Subscribing to partitioned streams\n\nBy default, the JS client subscribes to the first partition (partition `0`) in a stream. The partition number can be explicitly given in the subscribe call:\n\n```js\nconst sub = await client.subscribe({\n    stream: 'my-stream-id',\n    partition: 4, // defaults to 0\n}, (payload) => {\n    console.log('Got message %o', payload)\n})\n```\n\nOr, to subscribe to multiple partitions, if the subscriber can handle the volume:\n\n```js\nconst handler = (payload, streamMessage) => {\n    console.log('Got message %o from partition %d', payload, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await client.subscribe({\n        stream: 'my-stream-id',\n        partition,\n    }, handler)\n}))\n```\n\n## Logging\n\nThe Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.\n\nIn node.js, start your app like this: `DEBUG=StreamrClient* node your-app.js`\n\nIn the browser, set `localStorage.debug = 'StreamrClient*'`\n\n## For Developers\n\nPublishing to npm is automated via Github Actions. Follow the steps below to publish `latest` or `beta`.\n\nFor more technical documentation on the Data Unions API, see the [JS Client API Docs](https://streamr-dev.github.io/streamr-client-javascript/). These can also be rebuilt locally via:\n```\nnpm run docs\n```\n\n### Publishing `latest`\n\n1.  Update version with either `npm version [patch|minor|major]`. Use\n    semantic versioning <https://semver.org/>. Files package.json and\n    package-lock.json will be automatically updated, and an appropriate\n    git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n\n### Publishing `beta`\n\n1.  Update version with either `npm version [prepatch|preminor|premajor] --preid=beta`. Use semantic versioning\n    <https://semver.org/>. Files package.json and package-lock.json will be automatically updated, and an appropriate git commit and tag created.\n\n2.  `git push --follow-tags`\n\n3.  Wait for Github Actions to run tests\n\n4.  If tests passed, Github Actions will publish the new version to npm\n","browser":"./streamr-client.web.js","engines":{"node":">= 12"},"exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/index-esm.mjs","require":"./src/index-commonjs.js"}},"gitHead":"1ccf9ca99a31e5567b00c2448a4c047a0116a246","_npmUser":{"name":"hpihkala","email":"henri.pihkala@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.13.2","dependencies":{"qs":"^6.10.1","ws":"^7.4.5","mem":"^8.1.1","once":"^1.4.0","uuid":"^8.3.2","debug":"^4.3.2","lodash":"^4.17.21","sqlite":"^4.0.22","p-limit":"^3.1.0","p-queue":"^7.1.0","sqlite3":"^5.0.2","env-paths":"^2.2.1","p-memoize":"^4.0.1","quick-lru":"^6.0.0","bufferutil":"^4.0.3","idb-keyval":"^5.0.5","node-fetch":"^2.6.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.14.0","utf-8-validate":"^5.0.5","promise-memoize":"^1.2.1","readable-stream":"^3.6.0","@ethersproject/abi":"^5.1.2","@ethersproject/web":"^5.1.0","@ethersproject/sha2":"^5.1.0","node-webcrypto-ossl":"^2.1.3","@ethersproject/bytes":"^5.1.0","@ethersproject/units":"^5.5.0","@ethersproject/wallet":"^5.1.0","node-abort-controller":"^2.0.0","@babel/runtime-corejs3":"^7.14.0","@ethersproject/address":"^5.1.0","webpack-node-externals":"^3.0.0","streamr-client-protocol":"^9.0.0","@ethersproject/bignumber":"^5.1.1","@ethersproject/constants":"^5.3.0","@ethersproject/contracts":"^5.1.1","@ethersproject/keccak256":"^5.1.0","@ethersproject/providers":"^5.1.2","@ethersproject/transactions":"^5.1.1","@ethersproject/abstract-signer":"^5.1.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","util":"^0.12.3","sinon":"^10.0.0","buffer":"^6.0.3","eslint":"^7.26.0","ethers":"^5.1.4","core-js":"^3.12.1","express":"^4.17.1","process":"^0.11.10","ts-jest":"^26.5.6","typedoc":"^0.20.36","webpack":"^5.37.0","@types/qs":"^6.9.6","@types/ws":"^7.4.4","benchmark":"^2.1.4","ts-loader":"^9.2.0","weak-napi":"^2.0.2","@babel/cli":"^7.14.3","nightwatch":"^1.6.4","typescript":"^4.2.4","@babel/core":"^7.14.3","@types/jest":"^26.0.23","@types/uuid":"^8.3.0","jest-circus":"^26.6.3","webpack-cli":"^4.7.0","@types/debug":"^4.1.5","@types/sinon":"^10.0.0","babel-loader":"^8.2.2","chromedriver":"^96.0.0","pretty-bytes":"^5.6.0","eslint-loader":"^4.0.2","webpack-merge":"^5.7.3","@types/express":"^4.17.11","@babel/preset-env":"^7.14.2","@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/lodash.set":"^4.3.6","@types/node-fetch":"^2.5.10","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.0.2","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","babel-plugin-lodash":"^3.3.4","eslint-config-airbnb":"^18.2.1","eslint-plugin-import":"^2.23.2","eslint-plugin-promise":"^5.1.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.1.2","@types/lodash.uniqueid":"^4.0.6","webpack-bundle-analyzer":"^4.4.2","@babel/preset-typescript":"^7.13.0","@typescript-eslint/parser":"^4.24.0","@babel/helper-call-delegate":"^7.12.13","git-revision-webpack-plugin":"^5.0.0","eslint-config-streamr-nodejs":"^2.0.0","@babel/plugin-transform-classes":"^7.14.2","@babel/plugin-transform-runtime":"^7.14.3","babel-plugin-add-module-exports":"^1.0.4","@typescript-eslint/eslint-plugin":"^4.24.0","@babel/plugin-proposal-class-properties":"^7.13.0","babel-plugin-transform-class-properties":"^6.24.1","@babel/plugin-transform-modules-commonjs":"^7.14.0"},"optionalDependencies":{"bufferutil":"^4.0.3","utf-8-validate":"^5.0.5"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_5.6.0_1676306444886_0.21685859662016016","host":"s3://npm-registry-packages"}},"8.0.0-beta.0":{"name":"streamr-client","version":"8.0.0-beta.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.0-beta.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"609e3eed8976b0b26032fa37f0478a33590f0aab","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.0-beta.0.tgz","fileCount":279,"integrity":"sha512-aK3o71IJ6UjnkA3hjgDj5B36wMYZVo42bA44BS9tvnjmdmI6qBsvAdYpMx8A9meEM4weCk6Qd+5CUMZ9ykDKTg==","signatures":[{"sig":"MEYCIQCpHZCs1UdAaGdcBd+BOWVffitsNJKhVxJeiA2CXpST6QIhAOs+hgEEPmMPZAFtGUVWTfmGM+3kyXTagoS9L5kFca6r","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44616262,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj83HhACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqTnA//WCGkrHrMia6tq75N/xcglKOsmJMFunT/sZjjzLf4s+o1J/Pt\r\nkN9k5Q6k/vd3fFJeITZbbIruWl7ptY82dL/JLSuqiUULSmveIHbFNs++8L37\r\nAV0dIc5t4XVLFa/xBV/OxJSPErOMEzHsHjL00HqLkNpNiu2f5didI/F5IoJn\r\nVk0zS+D5tfJFosoZg0jQsXmPAp16ScW+eKX/Le658I9Bm+Rzlj0ehEk82VU5\r\nFM5baQ8uA4wPAdZlbHGeGwH9Ys6oU0HdYRFoYSQX3rEcK/549BCl+uGs29FD\r\nIlpzsnOCAfriBIddDFanhecGGD/Urng3a5jc6xPFcjaHOq22UGkbxNuO7bmm\r\ntKEFkZAQ98QOtb2SMDyLmaGPyUPq6D4a4GU22JwbmkVpg1GwgyTG2D8BDPeY\r\nrn/CUrrVztMQIHP1dBp+jxQaUlQ+Y6lBGoIH++Q0kkszSGuiAXH1oyb5FQD1\r\nQiea8P738q00t2Yb9GpCIzO3hdCrxh7iRJTtZ9WaszEXXpTwJj4Q6ZRHSzCc\r\nBhbaiqxn+vJ8wgicS3Zo2qCyVtd7tPRQZmhrD77RWmcXm/cFSvdnIm/AxJ3C\r\n4gvDkjBzRq+Uq+LR5zUoQ1IW2lkO3fu9Ic6w6A7KVJkpkgmt4guGM1HIWM4f\r\nr0u047P+CSFIi2MzHUDN0YDeyUn0HDbTY7I=\r\n=b2DP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n    - [Environments & frameworks](#environments-and-frameworks)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n    - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n### Environments and frameworks\n\n#### NodeJS\nNodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n#### Browser (Website/WebApps)\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.js\"></script>\n```\n\n#### Browser extension\nDue to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n#### React Native\nWe are actively working on React Native compatibility but currently the Streamr JavaScript Client is not compatible with React Native. To connect, pull or push data into the Streamr Network, use the [Broker integration pattern](https://streamr.network/docs/streamr-network/connecting-applications).\n\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network/client/v7.3/index.html\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThe client uses the Streamr Network's key-exchange by default. There is also experimental support for [Lit Protocol](https://litprotocol.com/). If you want to enable it, set `encryption.litProtocolEnabled` config option to `true`. \n\nWhen Lit Protocol is enabled, it is used as a primary encryption key store. The Streamr Network's key-exchange is still used as a fallback.\n\nFor the Streamr Network's key-exchange you can use these config options to control the decryption process:\n- `encryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `encryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n\nTo open publish proxy connections to multiple nodes on a stream partition:\n\n```js\nawait publishingClient.setProxies(streamPartition, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n```\n\nTo remove some/all proxies, call the same method with a different set of nodes. If the node list is empty, proxies are no longer used for the given stream partition:\n\n```js\nawait publishingClient.setProxies(streamPartition, [], ProxyDirection.PUBLISH)\n```\n\nBy default the client will attempt to open proxy connections to all of the nodes set in  `setProxies`. You can limit the number of connections by setting the `connectionCount` parameter. In this approach, if the client is disconnected from one of the nodes it will attempt to connect to another node by random:\n\n```js\n// Opens 2 connections, with an extra candidate to use in case of disconnections\nawait publishingClient.setProxies(streamPartition, ['0x11111...', '0x22222...', '0x33333...'], ProxyDirection.PUBLISH, 2)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"6ee5c88f30c906ab58c6883b6742f039190201d6","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.0-beta.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.0-beta.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.0-beta.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.38","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^109.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.0-beta.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.0-beta.0_1676898784865_0.29002011345465806","host":"s3://npm-registry-packages"}},"8.0.0":{"name":"streamr-client","version":"8.0.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"3d6a9cdff0c1293fa491e41c0f2d5461657461db","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.0.tgz","fileCount":271,"integrity":"sha512-qnJKFDpVqaEzwzV68DuySyxLXgS/5Q7pvzZbjtGS/6NuyOBqwP73SHM3SXPH/hB9nCFvB42yX1ArWmXvJzz4rA==","signatures":[{"sig":"MEUCIHOUc8UMMWxFAxtLYxxnebcPRea4bL1/V26/iBE1CZiuAiEAz38KGURaTiCHeCH1l4rErV6JYDXl0h/W6duIfgt9lJw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1225427,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj85XdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmopQw//YCSjGLw1aHws63bnJuDYUHZcxPR3W04ZrcaeBtTGjf2fn8UV\r\nDIdbPAD01TbyPhcTlfeVkThFh2vVqbW1K6QFqiSRifJf+YX3JXQfGSCgFB0u\r\n+xoWTEYEMLPJYaJhWIkf9RYDfscXlLgU7p+vPbYWhAhgXe2DexdN1hhc2ZgS\r\nRUP1i82COaSvHaDOwEycvXC8q3DT3QXi0tkLyFWm0Wvw9zH1TQ+Sjzxgr/ZS\r\nv0AVVhEu2958hGoqF20qvlpYJ5EUJK/vt+ym9p9d7z2AjZoSyRlqWlG66IBc\r\nCbokwDIkY0yWijcXLnxJL9dpB/u+64THhYl8szg3/xaXYHv6XXmB0xG7YgXL\r\nYhg88SE2JrpSUhLKRIvpoVCt0TnSn+HipqjLA51cU4RYtene2Q7sDrPftxKy\r\n8Mp+U2waDWRXSZxYrfXCt+nHrUsPbEKrae4LxRAunj+Hb7rNlNgVSG+5oKpz\r\nL9aCTbYB1GkM4Rh4htDwLLsFvm0PalU9GkgY0cKvnLO6DfZzHokBoW0VHbB3\r\n3KvjE113TwHs6nlzGHWfwmsoSPjBzaTza7fRhl91ays08j2hwfcbPTnr3YWU\r\n2ttn9gygioSY9JPpIC7x6S3NSoyOm7/+XldZJVJTRsmYySsPh29pI/JALfhH\r\nxvd89tCJ7vB1y1vH7VC2fI3W9kJNEinHNmY=\r\n=77oV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"b1e9722d0def7e9198c42e93f0a80e8f35a47b1a","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.38","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^109.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.0_1676907996865_0.4898601258472002","host":"s3://npm-registry-packages"}},"8.0.1":{"name":"streamr-client","version":"8.0.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"1275ab0a31e6e0486424f83d76bca1128e61767a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.1.tgz","fileCount":279,"integrity":"sha512-opvkthBx4OhV3UPphxWOQpawUqE0ocR9dS5zcgeBU2kKfNw9PWNK+q9ca2fABpUlUK8lqqIUszHiay7rk99A6g==","signatures":[{"sig":"MEUCIQDo/f2lB83wiil+7F5AhcHSTnZzRWLjEq37fLoD0pwYDQIgJcaWcALsMHf/uwVfxI6K5iRTNsGQ5ptTLDdljgEjm4k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44618434,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj86KPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqZww/+PsNJ6JS4QMl94Y5uZz70tp7ksjzm2zPg+ez0E9+fz3I/DNgm\r\nrARm8lur6CgXGeO+FpPP/Tl/MnYJRj/wOKM/enMfO4FkiaIs1KbtgoOFGb5D\r\nc27WHvbm4VJS9YwJn+8Io11nJMwVjJqx7nx4DnjIAIvv/INLBHTbtjZ4ViVX\r\nHgBOuVsaEveJE8jxXmZDbE0pARAIzWWzDt91UOgq679/lBP0w2Ghia6Hmh0e\r\nZN9Iu7IJdV7EJxvorQlldHS+zunJg2C97O4xsX6Tv17oQWfmE0bd4YpF00nx\r\nuXyDoYSD8FEeht0KupMWchNuczmq+A+je5nmbnfbp2EmBcZR+nQOsagqVzbS\r\nZZFWWYjEGakeQgAkB3j9Vc/3uw3Bd54f56KysBwl1ADFqeMk+LCRYCZkAii6\r\n8F3dh4hiiOjxVOm1FGAKci/0xERyK0ypYJ/CuFvB+yJ8LqVE2tmRRXdhEaOI\r\nP3V1sIyDKDEAkW5B/fBlAhUTy7dGLP3hoqLqUO65IAnwkU/FR/WhqeNHsOCn\r\nAgMyddKoSGrQcRYbH7OwpsZu5uWGLsWcQ50iJGxD8lvF1t7HXYxVfKs3rbAx\r\nK5sX19k6qTbSUIes/WoUQvxqESLwlWZa+3L5k8S3xRXmpB+05wtbXzT/JHfK\r\nkjkP2G7tlqaMiSPASUqTCST7AbsrdRJf0mc=\r\n=6sxy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"994b129694deb3743f9bdc2e00f4846c40a31253","_npmUser":{"name":"juslesan","email":"santeri.juslenius@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.1","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.38","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^109.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.1_1676911247155_0.85281507086468","host":"s3://npm-registry-packages"}},"8.0.2":{"name":"streamr-client","version":"8.0.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"6927f5a95da3879e2c2954ba05d672a07639e63c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.2.tgz","fileCount":279,"integrity":"sha512-ydJwgySgt5+xvpacBjqvRhsOR6FT1sDK9g705t/yi+6yZK/NvzGn074J4rGhGydEc6sjCBvhERlGm+qrtScpGg==","signatures":[{"sig":"MEQCIC0X9420Y4MdOJXC300h/UmrH6kLdg1aDwv+BBc0XwbdAiAYmGhPDrCoW83m3GvSjaQ+iAgRJmLcf4UEwMeanka2Kg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31265405,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/LMjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr8gg/5ATBhbgf3EDxPqaZCbY5Jt5YcYr2ow0krBmcteO6wnX6ZygEH\r\nK0ovWerxJGQFZci05aFvjRVj9wW0IIimmiGzY5P0rsmbX7vU1elWBPEheP+g\r\nkJnfObF12GR1KG4TuTkQcQr3BvCkKdCmIQRCx5qCzP8bnhyZki5JlgbIBM6A\r\n4h/XVBAuPBQSCUzEBH6tuRd/T3ktl/QNy19yFIZrJ0OpKtUasrVXZZ2UcA7X\r\nYOADuv24Ql/95d9v4gb9DUAqk58WBj1xuuvKXwiB2x/2/Am8bsDvqBSum+aB\r\nlWeesJzYn8DwIyoihVR7MsPn4mgkonu/XeILk5pcYIEiSLy2uYghEmQzBL3s\r\nDvyOhPS+D5v+RR3UA/deHYbkjDvOQmGJtbGJVtnw0U+3JpRq3yfPrBFzNQAB\r\nYgdUvpp0Dcg9I74Q1E2rz1RopEes+hP6gx34J8zUagIqB84E7jIrp1x5Qhzo\r\nl10iBwZi1KfydF7Tx1vQwJqApiJRw2mIprG4NOr+/wmIC9RSW+YUA45LBu0q\r\nm4QQRThy3HRMNShyx3pxkhwskPirr/hEET3tdpYNktk/bHZyw6lWbtq3kxMJ\r\nK66PZ4ZAJoarMirjAvl/b9ckQmGHBCDAWryoJuZKAwBvZKXN2V9s8EgFQfAK\r\npEBmf1qsB0xccCsHmzqFVSETPrzehhp0iW4=\r\n=EoT5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"e66a75a30cf4d3d079433609a3828b4f4f78e298","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.2","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.2","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.42","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^109.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.2_1677505314744_0.41175151215520844","host":"s3://npm-registry-packages"}},"8.0.3-beta.0":{"name":"streamr-client","version":"8.0.3-beta.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.3-beta.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"795b5ab693571d9711dcfbd0898beb239bf6f193","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.3-beta.0.tgz","fileCount":291,"integrity":"sha512-6v+W1izmfePPiwoafS/7hW+6iy6VybvLmtOqLcBo6rfiIH8nOmnNaHGC/5BEKAhzCvZbXcpvk055w+KAzQo2cg==","signatures":[{"sig":"MEQCIBffCGjTdgRbWfL+PmoUCF2YqRu3iDP43O9ggkYZgrz+AiAAi2M01k2X2BVsdN8Z5F+EyzVO/GuO87QEK8lXiiQ/Qg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33378963,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkCHCIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoP9w/8D+7IaKOXLxzwWYB0e/Zevi+Ihr5MVIaknu/BkcDyuraHCDol\r\napw6RGplQjCXQQ+z3XQ8qFKRoAPD53S1ZY5YX6IzZxK5qMfetoV4pKSW4z8C\r\nYGHqfsaMWPHDjMiSkW6qLr6nUfx1hAhDR8BvZme2DGbaF2sTVUltn2HI1o0v\r\nckRzG+FizgE7Q3BNVjYrPWbEUcyAcoOyT+uutQ8+oGxkCMJ+BwDMqziNCNnI\r\n6EtX/kV+c503o5pat2ZF5PXJVF/7y5UXcDSe52rCGZ/PCNxyM4BToBhYqSRD\r\n8ZFGClx9l6eVOTYDQx2kTjThl4aprENkgSNyALLrRevaZpPGA6LlOxPn8Hi9\r\nlDAgNQxfqE3zHigaO4bv4AA/K/MRu0dHhLOm3DCqnBZI2sr/UVkDLRaHiLu0\r\neZCV1iBvqyKSOd9gq+30++dRVhhhE8m4GX+m/rmO42RzwCIITRoQlv/5Gi42\r\nlrL6pFlKpjZ3opMykKah4X2NZc7/rrCdRZ3hxO7gFI3dsBdkDYQYZrcRx5cP\r\nn2FhMHZAUsmaF4AqJO+y7rURCC+0GfBzSwhfu5KcRS1tZRmZKjzxFRa7Lwro\r\n6AM421jK4DUsx5xAJJmJmJ/UZBb6uADK6ig+5ET+UknmfXg1hWt6k0+b9QEH\r\nJ/1YX2W58SORl5XUrdEFvq0Cyg4Gndf4ZhY=\r\n=wHoa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n    - [Environments & frameworks](#environments-and-frameworks)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n    - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n### Environments and frameworks\n\n#### NodeJS\nNodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n#### Browser (Website/WebApps)\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>\n```\n\n#### Browser extension\nDue to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n#### React Native\nWe are actively working on React Native compatibility but currently the Streamr JavaScript Client is not compatible with React Native. To connect, pull or push data into the Streamr Network, use the [Broker integration pattern](https://streamr.network/docs/streamr-network/connecting-applications).\n\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network/client/v8.0/index.html\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThe client uses the Streamr Network's key-exchange by default. There is also experimental support for [Lit Protocol](https://litprotocol.com/). If you want to enable it, set `encryption.litProtocolEnabled` config option to `true`. \n\nWhen Lit Protocol is enabled, it is used as a primary encryption key store. The Streamr Network's key-exchange is still used as a fallback.\n\nFor the Streamr Network's key-exchange you can use these config options to control the decryption process:\n- `encryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `encryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n\nTo open publish proxy connections to multiple nodes on a stream partition:\n\n```js\nawait publishingClient.setProxies(streamPartition, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n```\n\nTo remove some/all proxies, call the same method with a different set of nodes. If the node list is empty, proxies are no longer used for the given stream partition:\n\n```js\nawait publishingClient.setProxies(streamPartition, [], ProxyDirection.PUBLISH)\n```\n\nBy default the client will attempt to open proxy connections to all of the nodes set in  `setProxies`. You can limit the number of connections by setting the `connectionCount` parameter. In this approach, if the client is disconnected from one of the nodes it will attempt to connect to another node by random:\n\n```js\n// Opens 2 connections, with an extra candidate to use in case of disconnections\nawait publishingClient.setProxies(streamPartition, ['0x11111...', '0x22222...', '0x33333...'], ProxyDirection.PUBLISH, 2)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"8e0c09de403775a4dae3053ddd794099922a43ec","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.3-beta.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.3-beta.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.3-beta.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^109.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.3-beta.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.3-beta.0_1678274696121_0.34338360592053285","host":"s3://npm-registry-packages"}},"8.0.3":{"name":"streamr-client","version":"8.0.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"715bce232ed3dc51b27381dd300670f1b7672780","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.3.tgz","fileCount":291,"integrity":"sha512-QrtE3i88EvUBluJX2ODFZhI5QDSILLfOKE6LMur+by+eiTT3Zcz9vd+blr2JFZh3Z+ONb5gnJacdWWWRipWngA==","signatures":[{"sig":"MEYCIQC+VqPDUUORlpk54Pa7Y7jNdBCgs/Sgu2aSVekVDWsq/wIhAO7+wZSyGvCwYvCoshk10h4KEtS3c+90b0l6YsXrg9Gz","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33378858,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkCHfeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo8dQ/9Eq2pbDvlTAiaII12HSWpHBcQtwjDtvIqSuQahjCHXD56iPJK\r\npz4eOXT9bzJbNX6bs2G6Uy6qkgQjyrLBpTqg1tY1J/KAB72mchCkCZRSwDVU\r\ncOeI082QpPn0HsAlGuviqY9WLTncRd7VMomr9MwI4M/kHJoSaqepgattVrfr\r\nW/sbuQ67pR+MA8UCl+Rs+S13FvpwJob/+xY5we6iemAzkj7UNGESRqCiOCnU\r\n+nhATxBrux5Fo3lh+omnSwpzct0YWRT72AqBjz9W2xsQQk/i4HBMSg6B8AmE\r\n4Aaso3zJVDk0bHIS/bIhF+hXPDtNS7yqf5NtC/ckbTt+xM6IH2kJW0XrJmZB\r\nPN8NoFJ1m7f5cpz/GjCxpvssd/HcLinY6JMXWtlha06SynigxRdEdDGXTiIV\r\npuCBpD1sBMpTIqxxqq0r02oevmXlryDsFHCOzC2GM2qhEZjzvqDSCFzk6T3b\r\nV7K9LLimeYWJQPOKRiQZK8lEYFT3szv/h0UNpgPK111MVjrgStm3mwfDMpqw\r\n37zeFfF7Qqgf8cCkWj33j/4CxnZ66Vcn0Mq2ihFYu67hAs0A6IKogpI55Yl/\r\na1qM9P5dwdcgHio0rW+Td/wJeZPgWESms5y/EgUOU69eZEtd7xuWyW7Ct9oD\r\nBqhpwQpEKmB9iG4jsdvl8Kn5nptQsgl0vSM=\r\n=LE8g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"a5d127545870a877a02bb5eb11e1ed4b264afb3e","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.3","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.3","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^109.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.3_1678276574323_0.6087818254847779","host":"s3://npm-registry-packages"}},"8.0.4":{"name":"streamr-client","version":"8.0.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.0.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"5308bd546ea08d13521245783aa78d56cd2147e9","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.0.4.tgz","fileCount":288,"integrity":"sha512-e+d1DVYik1NzeFAkCwC4cJAbrgP+EpFCMIpgRhiah0FBrEFQYBaCEB8PIUrJpqzt0CNIxHGV8NbI3Oqp5lMiDw==","signatures":[{"sig":"MEYCIQCC9dH12UPCYfjjfOXRc5QvAEAcrfI26j8nd52kzLaiKgIhALHK4zkfKjSBBwml+Ee5/MKGh799zjeo1d+khbljDaaR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33389210,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGILtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoI+A//b0FJnzdYDmi5NvWYbD/881I3vlvN8xkc6hjy1qpP75WDr+Ei\r\nGed0W5JAOLg8oNyc+X73r1WBhqRyvT6GNjxX5QgCav/ZX8jm8QLh2fGihaY1\r\n7Ujaxm0F2so4bebz2USnD975N/PlZNTrM1I0/0RTuzuQ39UMNLmAh1T8mHmh\r\nNwLKhmULvzSKW+DAeEPHtRxatqoZ52K/rC4VLsKJ4/QPbL9O42eqJwu1BieN\r\nYtf9RZNtTS5y5eEc9O8jE3TbirYo673+zmsYYW+1qt131WSgXrguyv+6DH8x\r\noKN2vN4SkAfIJykkCUSCWD6BB8NpaZenT1Hj0++jyJagTZEzdqO0bja6Sc2R\r\npFGtDJ5D1jnM7J+j/CS5BPOldrefS0m1bwrXf1lSo4vrbjt+s+q3As/KS+ZK\r\nItPJuxO0EGQFjZO7FvmwEgKUVwJhin/6TFt4zPFAWM0y2EG8bg16DjcGB9Xf\r\nyJoYgYJJQaJIdqR8krL2nQlX40N/Eo/sLXHWF6bt1qpWsbf/idivVsprsif6\r\npUKsDbsqa943SlqXz7WKOmfyDI8lFxYcZ5haS41hBFSvNzTpVev7uCd4oo+j\r\nXaIyRzsl3wixSbwIPefOEJyL2YWix2omuE4pgcJ1DqzbnSJ+Y/xGkVLgm5vr\r\n7pC4tws8HlqvTdf2O1oF6aaZfeQdUPpB3AE=\r\n=OmUb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"6bbcadbb4694fe4304b45903e7b5ae8ab5d46200","_npmUser":{"name":"juslesan","email":"santeri.juslenius@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"ajv":"^8.8.2","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","idb-keyval":"^5.1.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.0.4","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.0.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.0.4","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^110.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.0.4","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.0.4_1679327981063_0.6900538518173396","host":"s3://npm-registry-packages"}},"8.1.0-beta.0":{"name":"streamr-client","version":"8.1.0-beta.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.1.0-beta.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"89e3f13a4a3500c2bc0877f613f1b22345ee505c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.1.0-beta.0.tgz","fileCount":296,"integrity":"sha512-7I34Var2fSRdzGvoUpyWzwL4ZGQTjQ3OET51f+If+i9k8nrCJJr4d4Pi+q8Tx5oomVY+exPgHqs8pzAbL8C1Ug==","signatures":[{"sig":"MEYCIQCvldvcjzPFSdJU2bMWvJ4pkcT/anr9NMvyDWrUyQFjZgIhAKrsWNQmRXsZbhdGAy63LA1eADbUGmDHTIimBC35eQL2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33435666,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGcCKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrNMA//XWO1110eSKPohNUuq71+ZDrrzoAlZkuB2EaCdvVQe/NKbox5\r\nr77BcXtC5XnrmruiHw5EcapkzKo09+BaDWRfRSNE2TlD569Cktycxee75fMM\r\nUiNN8VbGCLhCi0qyhSt+XKK+ZX8m7op3Hn6/799vdUrDc+QcQGwToycfemdY\r\nRY4GJKCtAcrkkHpvN0Vermd0ILi/8diQUFx5CU/v9iuqPkHzjsl2ZkIT+xUX\r\n0vEVN+mYpLnhGwI+aA4Ge2lrOzGht5g3RBBLVoWTuA3Ih3KUNZaJT5F2d8bs\r\nOUDVtk1it2tgr94/VA1N1TvyRI9NfgDh8Zrq8Re0AqQX9wits55YJGPI5KHN\r\nsVJDEtGu6eu7vnfMlpHRhnL2yVKqkzREYhhJTZnkpGy3Y5oCZqRdWL9pm7u5\r\nBYay/JaP4MYx0Sm6UY+NH0LgWfk+ufVgLlvJWM+rS+gZdTt6qjnJDXu272cI\r\n1rIm13gSD6ou9P0NdTztqUninPKH+piVo5Ki5ek8jZAB4AP7dbxQiDKPEEFu\r\neMMfYSPzyC3x6SunjY4cHsYk8ZcKejsjEXYs6ldCd5T0BoxsO+jCpPOzdAMA\r\nM8uxHaeDLr/7/ihk8k+EtUN66Q+P4NSRTgz8WIUdpF37IO++gYHzkvctGrqz\r\nCthRdeElJYaevvTaWuIdUQv9AFLz52+0GwQ=\r\n=NFYz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"1320\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThis library allows you to easily interact with the [Streamr Network](https://streamr.network) from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages, as well as contains convenience functions for creating and managing streams.\n\nPlease see the [Streamr project docs](https://streamr.network/docs) for more detailed documentation.\n\n## Contents\n- [Getting started](#getting-started)\n    - [Subscribing](#subscribing)\n    - [Publishing](#publishing)\n- [Setup](#setup)\n    - [Environments & frameworks](#environments-and-frameworks)\n- [Usage](#usage)\n    - [API reference](#api-reference)\n    - [Client creation](#client-creation)\n    - [Creating a stream](#creating-a-stream)\n    - [Subscribing to a stream](#subscribing-to-a-stream)\n    - [Publishing to a stream](#publishing-to-a-stream)\n    - [Requesting historical messages](#requesting-historical-messages)\n    - [Searching for streams](#searching-for-streams)\n    - [Interacting with the `Stream` object](#interacting-with-the-stream-object)\n     - [Getting existing streams](#getting-existing-streams)\n    - [Stream access control](#stream-access-control)\n    - [Enabling storage](#enabling-storage)\n    - [Utility functions](#utility-functions)\n- [Advanced usage](#advanced-usage)\n    - [Metrics publishing](#metrics-publishing)\n    - [Stream partitioning](#stream-partitioning)\n    - [Disable message ordering and gap filling](#disable-message-ordering-and-gap-filling)\n    - [Encryption keys](#encryption-keys)\n    - [Proxy publishing and subscribing](#proxy-publishing-and-subscribing)\n    - [Logging](#logging)\n\n## Getting started\n\n### Subscribing\n```js\nconst streamId = 'streamr.eth/demos/helsinki-trams'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n\n### Publishing\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n\nMore examples can be found in the [examples repo](https://github.com/streamr-dev/examples).\n___\n\n\n## Setup\n\n### Installation\nThe client is available on [npm](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\n### Importing `streamr-client`\nTo use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n### Environments and frameworks\n\n#### NodeJS\nNodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n#### Browser (Website/WebApps)\nFor usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n\n```html\n<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>\n```\n\n#### Browser extension\nDue to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n#### React Native\nWe are actively working on React Native compatibility but currently the Streamr JavaScript Client is not compatible with React Native. To connect, pull or push data into the Streamr Network, use the [Broker integration pattern](https://streamr.network/docs/streamr-network/connecting-applications).\n\n___\n## Usage\n\n### API reference\nSee https://api-docs.streamr.network/client/v8.0/index.html\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\nBy default, the `StreamrClient` publishes telemetry metrics to the network at regular intervals. See [Metrics publishing](#metrics-publishing).\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nYou can also create a stream by defining the address in the provided id. Please note that the creation will only succeed if you specify the same address as provided for authentication when creating the `streamr` instance:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await client.createStream({\n    id: `${address}/foo/bar`\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\nMore information on Stream IDs can be found under the [stream creation project docs](https://streamr.network/docs/streams/creating-streams)\n\n### Subscribing to a stream\n```js\nconst subscription = await streamr.subscribe(\n    streamId,\n    (content, metadata) => { ... }\n)\n```\nThe callback's first parameter, `content`, contains the value given to the `publish` method.\n\nThe second parameter `metadata` contains metadata about the message, e.g. timestamp.\n\nUnsubscribing from an existent subscription:\n```js\nawait streamr.unsubscribe(streamId)\n// or, unsubscribe them all:\nconst streams = await streamr.unsubscribe()\n```\n\nGetting all streams the client is subscribed to:\n```js\nconst subscriptions = streamr.getSubscriptions()\n```\n### Publishing to a stream\n\n```js\n// Here's our example data point\nconst msg = {\n    temperature: 25.4,\n    humidity: 10,\n    happy: true\n}\n\n// Publish using the stream id only\nawait streamr.publish(streamId, msg)\n\n// Publish with a specific timestamp as a Date object (default is now)\nawait streamr.publish(streamId, msg, { timestamp: new Date(1546300800123) })\n\n// Publish with a specific timestamp in ms\nawait streamr.publish(streamId, msg, { timestamp: 1546300800123 })\n\n// Publish with a specific timestamp as a ISO8601 string\nawait streamr.publish(streamId, msg, { timestamp: '2019-01-01T00:00:00.123Z' })\n\n// For convenience, stream.publish(...) equals streamr.publish(stream, ...)\nawait stream.publish(msg)\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\n// Fetches the last 10 messages stored for the stream\nconst resend1 = await streamr.resend(\n    streamId,\n    {\n        last: 10,\n    },\n    onMessage\n)\n```\n\nAlternatively you can fetch historical messages and subscribe to real-time messages:\n```js\n// Fetches the last 10 messages and subscribes to the stream\nconst sub1 = await streamr.subscribe({\n    id: streamId,\n    resend: {\n        last: 10,\n    }\n}, onMessage)\n```\nIn order to fetch historical messages the stream needs to have [storage enabled](#enabling-storage).\n\nResend from a specific timestamp up to the newest message:\n```js\nconst sub2 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n            sequenceNumber: 0, // optional\n        },\n        publisher: '0x12345...', // optional\n    }\n)\n```\nResend a range of messages:\n```js\nconst sub3 = await streamr.resend(\n    streamId,\n    {\n        from: {\n            timestamp: (Date.now() - 1000 * 60 * 10), // 10 minutes ago\n        },\n        to: {\n            timestamp: (Date.now() - 1000 * 60 * 5), // 5 minutes ago\n        },\n        // when using from and to the following parameters are optional\n        // but, if specified, both must be present\n        publisher: '0x12345...',\n        msgChainId: 'ihuzetvg0c88ydd82z5o',\n    }\n)\n```\nIf you choose one of the above resend options when subscribing, you can listen on the completion of this resend by doing the following:\n\n```js\nconst sub = await streamr.subscribe(options)\nsub.once('resendComplete', () => {\n    console.log('Received all requested historical messages! Now switching to real time!')\n})\n```\n\nNote that only one of the resend options can be used for a particular subscription.\n\n### Searching for streams\nYou can search for streams by specifying a search term:\n```js\nconst streams = await streamr.searchStreams('foo')\n```\nAlternatively or additionally to the search term, you can search for streams based on permissions.\n\nTo get all streams for which a user has any direct permission:\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...'\n})\n```\nTo get all streams for which a user has any permission (direct or public):\n```js\nconst streams = await streamr.searchStreams('foo', {\n    user: '0x12345...',\n    allowPublic: true\n})\n```\n\nIt is also possible to filter by specific permissions by using `allOf` and `anyOf` properties. The `allOf` property should be preferred over `anyOf` when possible due to better query performance.\n\nIf you want to find the streams you can subscribe to:\n```js\nconst streams = await streamr.searchStreams(undefined, {\n    user: '0x12345...',\n    allOf: [StreamPermission.SUBSCRIBE],\n    allowPublic: true\n})\n```\n___\n### Interacting with the `Stream` object\nThe `Stream` type provides a convenient way to interact with a stream without having to repeatedly pass Stream IDs.\n#### Getting existing streams\n```js\nconst stream = await streamr.getStream(streamId)\n```\n\nThe method getOrCreateStream gets the stream if it exists, and if not, creates it:\n```js\n// May require MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.getOrCreateStream({\n    id: streamId\n})\n```\n\n#### Stream access control\n\nThere are 5 different stream permissions:\n- StreamPermission.PUBLISH\n- StreamPermission.SUBSCRIBE\n- StreamPermission.EDIT\n- StreamPermission.DELETE\n- StreamPermission.GRANT\n\nYou can import the `StreamPermission` enum with:\n```js\nconst { StreamPermission } = require('streamr-client')\n```\n\nFor each stream + user there can be a permission assignment containing a subset of those permissions. It is also possible to grant public permissions for streams (only `StreamPermission.PUBLISH` and `StreamPermission.SUBSCRIBE`). If a stream has e.g. a public subscribe permissions, it means that anyone can subscribe to that stream.\n\n\nTo grant a permission for a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.grantPermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH],\n})\n```\nOr to grant a public permission:\n```js\nawait stream.grantPermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\nTo revoke a permission from a user:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.revokePermissions({\n    user: '0x12345...',\n    permissions: [StreamPermission.PUBLISH]\n})\n```\nOr revoke public permission:\n```js\nawait stream.revokePermissions({\n    public: true,\n    permissions: [StreamPermission.SUBSCRIBE]\n})\n```\n\n\nThe method `streamr.setPermissions` can be used to set an exact set of permissions for one or more streams. Note that if there are existing permissions for the same users in a stream, the previous permissions are overwritten. Note that this method cannot be used from a stream, but via the `StreamrClient` instance:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait streamr.setPermissions({\n    streamId,\n    assignments: [\n        {\n            user: '0x11111...',\n            permissions: [StreamPermission.EDIT]\n        }, {\n            user: '0x22222...'\n            permissions: [StreamPermission.GRANT]\n        }, {\n            public: true,\n            permissions: [StreamPermission.PUBLISH, StreamPermission.SUBSCRIBE]\n        }\n    ]\n})\n```\n\nYou can query the existence of a permission with `hasPermission()`. Usually you want to use `allowPublic: true` flag so that also the existence of a public permission is checked:\n```js\nawait stream.hasPermission({\n    permission: StreamPermission.PUBLISH,\n    user: '0x12345...',\n    allowPublic: true\n}\n```\n\nThe full list of permissions for a stream can be queried by calling `stream.getPermissions()`:\n```js\nconst permissions = await stream.getPermissions()\n```\nThe returned value is an array of permissions containing an item for each user, and possibly one for public permissions:\n```js\npermissions = [\n    { user: '0x12345...', permissions: ['subscribe', 'publish'] },\n    { public: true, permissions: ['subscribe']}\n]\n```\n\n#### Updating a stream\nTo update the description of a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.update({\n    description: 'New description'\n})\n```\n\n\n#### Deleting a stream\nTo delete a stream:\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nawait stream.delete()\n```\n\n\n\n### Enabling storage\n\nYou can enable storage on your streams to retain historical messages and access it later via `resend`. By default storage is not enabled on streams. You can enable it with:\n\n```js\nconst { StreamrClient, STREAMR_STORAGE_NODE_GERMANY } = require('streamr-client')\n...\n// assign a stream to a storage node\nawait stream.addToStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n```\nOther operations with storage:\n```js\n// remove the stream from a storage node\nawait stream.removeFromStorageNode(STREAMR_STORAGE_NODE_GERMANY)\n// fetch the storage nodes for a stream\nconst storageNodes = stream.getStorageNodes()\n```\n\n### Utility functions\n\nThe static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`.\n```js\nconst { address, privateKey } = StreamrClient.generateEthereumAccount()\n```\nIn order to retrieve the client's address an async call must me made to `streamr.getAddress`\n```js\nconst address = await streamr.getAddress()\n```\n\n## Advanced usage\n\n### Metrics publishing\n\nBy default, the `StreamrClient` publishes metrics to the network at regular intervals. The metrics include, for example, information about data volumes passing through the node, and are attributed to your node id. Here's the content of the metrics messages:\n\n```\n{\n    node: {\n        publishMessagesPerSecond: number\n        publishBytesPerSecond: number\n        sendMessagesPerSecond: number\n        sendBytesPerSecond: number\n        receiveMessagesPerSecond: number\n        receiveBytesPerSecond: number\n        connectionAverageCount: number\n        connectionTotalFailureCount: number\n    },\n    period: {\n        start: number\n        end: number\n    }\n}\n```\n\nIf you don't want to publish metrics, you can turn it off in the client configuration:\n\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: false\n})\n```\n\nIf you want to use custom stream and/or reporting periods, you can specify the details like this:\n```\nconst streamr = new StreamrClient({\n    ...\n    metrics: {\n        periods: [{\n            duration: 3600000, // in milliseconds\n            streamId: \"my-metrics-stream.eth/hour\"\n        }]\n    }\n})\n```\n\n\n\n### Stream partitioning\n\nPartitioning (sharding) enables streams to scale horizontally. This section describes how to use partitioned streams via this library. To learn the basics of partitioning, see [the docs](https://streamr.network/docs/streams#partitioning).\n\n#### A note on stream ids and partitions\nThe public methods of the client generally support the following three ways of defining a stream:\n```js\n// Stream id as a string:\nconst streamId = `${address}/foo/bar`\n\n// Stream id + partition as a string\nconst streamId = `${address}/foo/bar#4`\n\n// Stream id + partition as an object\nconst streamId = {\n    id: `${address}/foo/bar`,\n    partition: 4\n}\n```\n\n#### Creating partitioned streams\n\nBy default, streams only have 1 partition when they are created. The partition count can be set to any number between 1 and 100. An example of creating a partitioned stream:\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: `/foo/bar`,\n    partitions: 10,\n})\nconsole.log(`Stream created: ${stream.id}. It has ${stream.getMetadata().partitions} partitions.`)\n```\n\n#### Publishing to partitioned streams\n\nIn most use cases, a user wants related messages (e.g. messages from a particular device) to be assigned to the same partition, so that the messages retain a deterministic order and reach the same subscriber(s) to allow them to compute stateful aggregates correctly.\n\nYou can specify the partition number as follows:\n```js\nawait streamr.publish({\n    id: `${address}/foo/bar`,\n    partition: 4\n}, msg)\n```\n\nThe library alternatively allows the user to choose a _partition key_, which simplifies publishing to partitioned streams by not requiring the user to assign a partition number explicitly. The same partition key always maps to the same partition. In an IoT use case, the device id can be used as partition key; in user interaction data it could be the user id, and so on.\n\nThe partition key can be given as an argument to the `publish` methods, and the library assigns a deterministic partition number automatically:\n\n```js\nawait stream.publish(\n    msg,\n    {\n        partitionKey: msg.vehicleId\n    }\n)\n```\n\n#### Subscribing to partitioned streams\n\nBy default, the client subscribes to the first partition (partition `0`) of a stream. Be aware: this behavior will change in the future so that it will subscribe to _all_ partitions by default.\n\nThe partition number can be explicitly given in `subscribe`:\n\n```js\nconst sub = await streamr.subscribe({\n    id: streamId,\n    partition: 4\n}, (content) => {\n    console.log('Got message %o', content)\n})\n```\n\nIf you want to subscribe to multiple partitions:\n```js\nconst onMessage = (content, streamMessage) => {\n    console.log('Got message %o from partition %d', content, streamMessage.getStreamPartition())\n}\n\nawait Promise.all([2, 3, 4].map(async (partition) => {\n    await streamr.subscribe({\n        id: streamId,\n        partition,\n    }, onMessage)\n}))\n```\n\n### Disable message ordering and gap filling\nIf your use case tolerates missing messages and message arriving out-of-order, you can turn off message ordering and gap filling when creating a instance of the client:\n```js\nconst streamr = new StreamrClient({\n    auth: { ... },\n    orderMessages: false,\n    gapFill: false\n})\n```\nBoth of these properties should be disabled in tandem for message ordering and gap filling to be properly turned off.\n\nBy disabling message ordering your application won't perform any filling nor sorting, dispatching messages as they come (faster) but without granting their collective integrity.\n\n\n### Encryption keys\n\nMessages published to a non-public stream are always encrypted. The publishing client creates the encryption keys and delivers them to the subscribers automatically. In most use cases, there is no need to manage encryption keys manually.\n\n#### Typical use cases\n\nA new encryption key is generated when publishing activity to a stream starts. The keys don't change during the lifetime of a client unless explicitly updated.\n\nAt any given time a subscriber can request a key from a publisher. When the publisher receives a request, it checks whether the subscriber has valid `StreamPermission.SUBSCRIBE` permission to the stream. If a valid permission exists, the client sends the encryption key to the subscriber. The subscriber can then use the key to decrypt messages which are encrypted with that key.\n\nTypically subscribers query the current encryption key. But if they need to access to historical data, they may query previous encryption keys. A publisher client keeps track of all previous encryption keys in a local database, so it can respond to historical encryption key queries automatically. Therefore the publisher needs to stay online if historical decryption of its data is something that should be supported.\n\n#### Manual key update\n\nYou can manually update the encryption key by calling `client.updateEncryptionKey(...)`. This triggers the creation of a new encryption key, after which the client starts to use that to encrypt published messages.\n\nIn practice, an update is needed if:\n\n- You want to prevent new subscribers from reading historical messages. When you update the key, the new subscribers get the new key. But as the historical data is encrypted with some previous key, those messages aren't decryptable by the new subscribers.\n- You want to prevent expired subscribers from reading new messages. When you update the key, but you don't distribute the new key to the expired subscribers, they aren't able to decrypt new messages.\n\nBoth of the use cases are covered if you call:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rekey'\n})\n```\n\nYou may want to call this method regularly (e.g. daily/weekly). Alternatively you can call it anytime you observe new expired subscribers (that is, someone bought your data stream for a limited period of time, and that period has now elapsed).\n\n#### Optimization: key rotation\n\nYou can optimize the key distribution by using `rotate` instead of `rekey`. The optimization is applicable if subscriptions haven't expired or been removed. In that situation you can update the key by calling:\n```\nclient.updateEncryptionKey({\n    streamId,\n    distributionMethod: 'rotate'\n})\n```\n\nIn detail, the difference between the methods is:\n- In `rekey` method, the client sends the new key individually to each subscriber. Every subscriber receives a separate message which is encrypted with their public RSA key. The `StreamPermission.SUBSCRIBE` permission is checked by the publisher for each subscriber before a key is sent.\n- In optimized `rotate` method, the key is broadcasted to the network in the metadata of the next message. The key is encrypted with the previous encryption key and therefore subscribers can use it only if they know the previous key (https://en.wikipedia.org/wiki/Forward_secrecy). As the key is broadcasted to everyone, no permissions are checked. Note that recently expired subscribers most likely have the previous key, therefore they can use that new key, too.\n\n#### Pre-agreed keys\n\nIf you don't want to exchange the keys via the network, you can use pre-agreed keys like this:\n\n```\nconst key = new GroupKey('key-id', crypto.randomBytes(32))\npublisher.updateEncryptionKey({\n    key,\n    streamId,\n    distibutionMethod: 'rekey'\n})\nsubscriber.addEncryptionKey(key, streamId)\n```\n\n#### Configuration\n\nThe client uses the Streamr Network's key-exchange by default. There is also experimental support for [Lit Protocol](https://litprotocol.com/). If you want to enable it, set `encryption.litProtocolEnabled` config option to `true`. \n\nWhen Lit Protocol is enabled, it is used as a primary encryption key store. The Streamr Network's key-exchange is still used as a fallback.\n\nFor the Streamr Network's key-exchange you can use these config options to control the decryption process:\n- `encryption.keyRequestTimeout`: max time (in milliseconds) to wait before a key request timeouts\n- `encryption.maxKeyRequestsPerSecond`: max count of key request to be sent within a second (i.e. it throttles the requests if it receives messages from many new publishers within a short period of time)\n\n### Proxy publishing and subscribing\n\nIn some cases the client might be interested in publishing messages without participating in the stream's message propagation. With this option the nodes can sign all messages they publish by themselves. Alternatively, a client could open a WS connection to a broker node and allow the broker to handle signing with its private key.\n\nSetting subscribe proxies can be useful for cases where broker nodes with public IP addresses do not exist in a stream.\n\nProxy publishing and subscribing are handled on the network overlay level. This means that there is no need to know the IP address of the node that will be used as a proxy. Instead, the node needs to know the ID of the network node it wants to connect to. It is not possible to set publish / subscribe proxies for a stream that is already being \"traditionally\" subscribed or published to and vice versa.\n\n\nTo open publish proxy connections to multiple nodes on a stream partition:\n\n```js\nawait publishingClient.setProxies(streamPartition, ['0x11111...', '0x22222...'], ProxyDirection.PUBLISH)\n```\n\nTo remove some/all proxies, call the same method with a different set of nodes. If the node list is empty, proxies are no longer used for the given stream partition:\n\n```js\nawait publishingClient.setProxies(streamPartition, [], ProxyDirection.PUBLISH)\n```\n\nBy default the client will attempt to open proxy connections to all of the nodes set in  `setProxies`. You can limit the number of connections by setting the `connectionCount` parameter. In this approach, if the client is disconnected from one of the nodes it will attempt to connect to another node by random:\n\n```js\n// Opens 2 connections, with an extra candidate to use in case of disconnections\nawait publishingClient.setProxies(streamPartition, ['0x11111...', '0x22222...', '0x33333...'], ProxyDirection.PUBLISH, 2)\n```\n\nIMPORTANT: The node that is used as a proxy must have set the option on the network layer to accept incoming proxy connections and must have joined to the stream that a proxy connection is wanted for.\n\nExample client config:\n\n```json\n{\n    ...\n    \"network\": {\n        ...\n        \"acceptProxyConnections\": true\n    }\n}\n```\n\nExample broker config\n\n```json\n{\n    ...\n    \"client\": {\n        ...\n        \"network\": {\n            ...\n            \"acceptProxyConnections\": true\n        }\n    },\n    \"plugins\": {\n        ...\n        \"subscriber\": {\n            \"streams\": [\n                {\n                    \"streamId\": \"STREAM_ID\",\n                    \"streamPartition\": 0\n                },\n                {\n                    \"streamId\": \"STREAM_ID2\",\n                    \"streamPartition\": 0\n                },\n            ]\n        }\n    }\n}\n```\n\n### Logging\n\nThere are two ways to set a desired logging level.\n\nYou can pass the logging level in the StreamrClient constructor as follows:\n```ts\nconst streamr = new StreamrClient({\n  logLevel: 'debug',\n  // ... more options\n})\n```\n\nAlternatively, when running your application in Node.js, you can provide the\nlogging level via the environment variable `LOG_LEVEL`, for example, by running\nyour application as follows:\n\n```bash\nLOG_LEVEL=trace node your-app.js\n```\n\nWhen defining both the environment variable takes precedence. Default logging\nlevel is `info`. Valid logging levels are `silent`, `fatal`, `error`, `warn`,\n`info`, `debug`, and `trace`.\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"69fdd0dadfe1b252eac928e84b8b9f3e02727d1a","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.1.0-beta.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.1.0-beta.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.1.0-beta.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^110.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.1.0-beta.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.1.0-beta.0_1679409289574_0.9877360600185112","host":"s3://npm-registry-packages"}},"8.1.0":{"name":"streamr-client","version":"8.1.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.1.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"c9df7990fd38e3e7712b4786d783b70e486a9d99","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.1.0.tgz","fileCount":296,"integrity":"sha512-shHP8Icg1y6ob37HWB4kcoI9hRpuQgog3lC9g9i7vJN5dkOi5OQmNCND4Kgr90MRoBTZgVV0GeWkanaTbtl/IQ==","signatures":[{"sig":"MEUCIFCUSEV77uH3zhk1P4ixHC+r36ics/zfdhyVfJhFqA+pAiEA3OPWSbghMNQk+IPMB2kWxLzr2i+3iKN+hciwDxBocWc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33404471,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkHFiQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoEEg/6Am+qKNNtVg6Z8qOVhMSmq0SRl5nEso1DAwh23+1Ha9NFiVlJ\r\nXVtvhbPiRpcZPXUC5ED7A8zQxiOR1KOTkd4WvEMs2KRj0xz69FZDVjcAvssC\r\nXqqcMC+jmwOvDSuySsSV7hpZHsuAc6BvjoD5ErtSARCzUSr9rKVJrFH+d9Qw\r\nTpA1U39n1vQ38cZNaF8Lr17GAEnSbMp71lEWlUC+zvGQvrIYu7RVXPYcLQoB\r\n3V/5yg2C9BsB1SZlngiRcC+YioQF9qjowFjhS/6WaZTtZB9g5G9rfBPtFKkA\r\nusCCGCQwHku213H3QzVM86HbxhmQxK4EUcq0EZOaMfkS0w4gPTFHOUJcCmeG\r\npfi6W8zi50hbe0rWtyWc3kdgLMrHXQOg90tu3YQoP9aBUQK2obnOpI/obG75\r\n3H19SByBqmg9EVtFX0SD+rsHME4+LGa/Ro5dG7lMLul0D3O/cgOLdiuM51xN\r\nvhPTlKNjKr5bQ55/AUO6CdZUK5xLQlEtni1G/o/77FVsd8L8j/0aXU34tFiz\r\nKgbCBbN2DRX6yAPeejyUT+t2kfSI3WtpCPZdBoMUxT81sbUkSCJseBNehrhH\r\nMYjMnO/lifBea+EaoO0VnSK5UJUctzxLP86wiSxD3StaxbyjbFqj6oLMf+FX\r\nqeKVNitg7//c3KFuMiGj/+A0B2HJvONpU0I=\r\n=BmhY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"e346301f92d851537b38333971aa2f2abb1a74a4","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.1.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.1.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.1.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.20","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^110.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.1.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.1.0_1679579280047_0.16158880355695437","host":"s3://npm-registry-packages"}},"8.2.0":{"name":"streamr-client","version":"8.2.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.2.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"1884015e19d0ca23379a4bf23fbceb6402230705","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.2.0.tgz","fileCount":290,"integrity":"sha512-4DoaxkbbI+WNoAsBROTrHZgsrbBryR2OxWofJg0t/84KWQOO2Mu3gpdw+sUnoP6yWcaUGkcbrVBNY2Hxht4kdw==","signatures":[{"sig":"MEYCIQC409aULzmYKb9Wn4P8GOnHYRTO4E3alc97z5GA9H8/hgIhAKQshKp+QXVNFfulL9sVhQ9xD/w0NtcpjfnSqEwgB/Ws","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33233241,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkNXg1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqMZxAApN07wUlXXtBekwL6g9dxeu61QPHTWdpQD7eClGKBzQLzJPMi\r\nJatWSkdSfCVLzhNlIA5yUZmPrrq8SXtDw20Zeggod7vSnLeq+TlLYE3TbojG\r\nXYAFuyACAsbNkO3OERSg1VW2zZ8ROLejJ9SXWHxC25qITt73f4bXW5l5hZzf\r\nZ8tMIzuIPiAgMELk9FwLsX6uMgC7OpaA+Bjy7uj/aeOfDhKHkJ5nKOqSEefq\r\nVSPLsBib6nWhNlU6hJQLlb3C8FEgQxlWvXgcOJaI/HBrXzgwwL1iCdnZUPvG\r\nYILmrgB+XXOgnHOSDZSh/0q3PtF6s/8SOtFjmToPWYa34Yx7V6trVQrmY9Xl\r\n2KvCHloF697LyDla5D8xMTIRvC6njVfFeMK/e1oqTl+qaVZB1iZuZv7fDTNj\r\ny3BARJecUbqx3fvizic080swLHmYY6XSMrByEvZeA6AYh1kFAyyIyYnZYVQm\r\noOJPCFILTH6a8pPXrdT6mVgym50+gV3qoEAaselubio9oynKjvNHiKR+GYRh\r\ndvO3Ki6WK6N9cbjooQl3gbbi8vnM7H7/pn91ucG/dEvuSk5xVpfWSDMDat2e\r\n1diwaGvu5f0Us3s1cDJxS3z73ErWmEd+uKyB+AlgJg/F1HK0IhMWV+WZh6wV\r\n9f4GcoF+JlzIBlYUQFMKrvefCg2T5T0vqCQ=\r\n=Z0oi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"eff34a93944b66b10958a7d8697a23a515394663","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.2.0","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.2.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.2.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.28","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^111.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.2.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.2.0_1681225780928_0.29840311514941864","host":"s3://npm-registry-packages"}},"8.2.1":{"name":"streamr-client","version":"8.2.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.2.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"kare","email":"kare.nuorteva@me.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"mmartinmo","email":"martin.moravek@streamr.com"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"2d8e5f60e9398d4a4bc6cfb3b7d4b25c9f446a02","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.2.1.tgz","fileCount":290,"integrity":"sha512-HI9LlYgmrCOG196jX26X+RJ60NgWDNMVQKXgQaYoxErxtqe3ZZkIrF/6/o9ytFTopNi026Ye72rl9pzMn2PE9w==","signatures":[{"sig":"MEUCIFpaVK+7trbgnF5aHTfueV/DpvpasUDTBAHdk6bBn+hpAiEA7GzQhvizngH+uiEc6a3NHVN7dfsOvTbTzX32oi3AUxU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32585701,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkOBrXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrw3A/7BYtxjeWwjzPNmKiEFavuHXdu0/+RBaoF24lmeeAs38KzkGhh\r\nLIyCcpjw49VQmoJpCyhgXV05F2QYMj4LNf+ncdyMNjJLU3vI9cozozHrAmaY\r\nrNzsrLQdwU+Nk+vDWg5NCZCohQazkIVRzKaTuM2410buIPdGvWUHqEQ/W8EH\r\naXjeNkbeksDcC+zrjaNXadOkzbpwwlzichlzRZWegdkhPvPkv+HH2A3oJY59\r\n0ueTc6mAFKWdt5eAdA9tURH5h4Uufm184OYBPp+NwiZEuH2SksP056IesFLu\r\nMBW235T0he+gONf6cUJClFbIVVdY+3qwGQU1BaVbO4yq7Ijgt7GwCLfWX4u7\r\nV55btInoi865aOUkOZClXDgpfdP2YnPuZhd7FxrfmuFJZ/M+l/gZr49w0w9h\r\nzN+E5jI4SQtfkQqzp1+TCvP3RHVU3xfteborSlzxN3iCwBhj3n+cpbZBOw0j\r\nwO/prAUMHB2kB7sjVcz4xR41FIYuQymvbOIcXITihTKTnPIkpYWfnGoHXFrd\r\nlzFE6u9bzH7v6IAv+2J5EivlZSnOdNWksUDx1PgugIhTY8mbFAsl5UJKqQGa\r\ndIZct5uBBxMSGwdmN3u4p9JtKJWqK4kCNvmwC2UN0xMLvjLniNs4Tq4PiHvL\r\nrToP4W9/M6hFpAaIwJC8IXU/8lWJm/wuGmo=\r\n=Ny+u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"49fa949059cd1cab61a96b61dba044ae0d1cb7de","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.1.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"16.14.2","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^8.3.2","lodash":"^4.17.21","split2":"^3.2.2","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^4.0.2","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^4.0.7","@babel/runtime":"^7.16.3","@streamr/utils":"8.2.1","utf-8-validate":"^5.0.7","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.2.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.2.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.28","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^1.7.12","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^8.3.1","webpack-cli":"^4.9.1","babel-loader":"^8.2.3","chromedriver":"^111.0.0","concurrently":"^6.4.0","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","array-shuffle":"^2.0.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.2.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^5.0.7"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.2.1_1681398487123_0.45935845038721657","host":"s3://npm-registry-packages"}},"8.3.0-beta.0":{"name":"streamr-client","version":"8.3.0-beta.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.3.0-beta.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"db11bff6b3f256116560c6506464687d66570c39","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.3.0-beta.0.tgz","fileCount":287,"integrity":"sha512-yn4aNADNr91QpN2fWWkDtaj4MI7HRYDBBeBNEbrwbhyoKFTFoNgnkmFJ963jC7SYRQCH2Dur00XywHL1sOuxow==","signatures":[{"sig":"MEUCIQCSmMRtU5LoxNmpvgL7XHEK9MViZSXH4q3k6DC3Nku20wIgPN3NeO12B5F3ooyh0wFBY9rZh3hLpDuVmMuYC6r2mqU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34320975,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkQRzQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrq/g/+N+HmoDk6wHyrN6B8k0OR3q45hz87s2dnRSZwha7Utxz6tka+\r\nWOzvqhBrRX7SqZODhuMkUqWcxLtJeRR12Cw5VWGZ9E1G2thLsdqvbkZHQASI\r\ncieik/707tlVManZzaQLIGc6uEX62/poK7E0htuBKud3l3IoeqVfEajPwmEi\r\nRAdsmdWxFmfFvnHd3WN0YYWoqJZgrdzX1v9euSz0mQ8sszaLHdF8sNEeZCy+\r\n80tKAK4gblUzDY3qN5H4ZH5Rz4wbg12Czkq95eIXhDzw5CyjXCld3kI1EYcd\r\n0DlI5Tj81do45hJKMlpPFBuvpMITxiq4C7pWitVve/Pwk/Bz8/lCfIz7oDr7\r\ngVAOGm1wBwkhrFZbHQrBuqTb+H1Gmva+PKm1iuCq3ctHfvCiqK+dEQZeW47Q\r\nvzAuIOCwpCjCtWWWHrBELqavhphVMVJwOxTuUd7xIL1D/cykFkuTz+E6uvQi\r\nr5xnU+0UFo0gxbeD3bP4gr/xC+gyfw10RCrtGeppMuWko1AJrV9uiRXErF/o\r\nB9+Bfwj/ZnVwSGz/FgIdtypNvnOgz8fPLVPDe//TI3CZwfPJT+CO/skZkQ1V\r\nBeZ61Rz7xbh7WJBIQhuq2O+SyUuiaeZsdZ+2Vi3N3clD13dIDqyPDXDunAlT\r\ny6GzeAC+m0OBCOwSy9jVs1d0Gce1M/bheDk=\r\n=34n3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/client/v8.2/index.html.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"4289f839347838ff6ee29f2a6a5b79c1620b590c","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","mem":"^8.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.3.0-beta.0","utf-8-validate":"^6.0.3","readable-stream":"^3.6.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.3.0-beta.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.3.0-beta.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.23.28","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^4.9.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.3.0-beta.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^1.1.4","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.3.0-beta.0_1681988815651_0.8716546457608769","host":"s3://npm-registry-packages"}},"8.3.0-beta.1":{"name":"streamr-client","version":"8.3.0-beta.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.3.0-beta.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"e1bd3848f685d1c8179ff09370e1091b2d4a4b6c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.3.0-beta.1.tgz","fileCount":290,"integrity":"sha512-d6Cbf8lyb9IbDxPyxgW2HxR/utrkr2xQTt/Z3u+rvKlDxd0JzZzYWrSXbRINjTQ9dpjP1gn8DQOD/EfFbGLsrQ==","signatures":[{"sig":"MEQCIBM2E66OySyuQKMOscKkUx5XnYXToI/SePpzImCCQYhWAiAhigHrm7+sC0RDb6J+Jn5HxJJgdh46aOtPHunz0Bmm/A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35565256,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkR9TkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoIoA//UqMIQLll66mqefTF1IuG/G27oqmQOIN5S9xiOmnSqoSwqzlz\r\n2KhmFXMrQ/yKF2V9CWoCRVkdZXNQ9OYiMJSBn5PSNG2/tCweigy7StgnzLu4\r\nSdYtmTV3nKEYVEoSGgzJgc8M6GHPXnooUG0HzSZDaxU+Ne3K4oHOV/1AGQu4\r\nRrxJXibIOSyJvj/bIXRdr6/Ptwao/06Wlcmj09SfDkXxPhTUF3EfwB9twzZS\r\nC+7FNLIgFc5/zb5b5zlxvhfYr3KB2odOLLNyCsgzt2I6ZZm/RhYnRjCkwk5g\r\nOBIgCEAHXMlCdRIduS/NCZGxS1/Hz9Lv8RkPaEGv5UXduyRVdrioji2V46wk\r\n9FVS3LEqO/fORh74R4j5fnAYnw5NKuooFGq2Tylhrs01EtBo28e4l0kmkySn\r\niA0CGSoZOlpItw8n3imrfS6+cjKOYjqGO9xx4Jp7IUETDKg3CaYMZgUti8kN\r\nx9sF5Qzb+aIqnDmil2dhjhGpuyKAUeACbUZI1Q0MBtqZqxUBvXP8mk5vYa04\r\nH22SHn7jHNZ1xBHww9vS/ejcGoc8mFACFxBYvex+XejrEeRHy5Ss7G25kATD\r\nsHLegFrWA5eM9oVEIuDE2iZnTKzM87tFL5XsGHG5IAGGvrLcePlWufG7hdCq\r\niiH7n3FbY8X83qUctmbEVn96GGUEKatb1iM=\r\n=sCtt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/client/v8.2/index.html.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"3d8f2030928a221a922e93d62cc045a488e6bbd5","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.3","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.0.0","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.3.0-beta.1","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.3.0-beta.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.3.0-beta.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.50","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^3.2.1","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.3.0-beta.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.3.0-beta.1_1682429155877_0.4766608246862505","host":"s3://npm-registry-packages"}},"8.3.0":{"name":"streamr-client","version":"8.3.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.3.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"9aa77e9d8929c5220357e97698153db2f0bc6001","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.3.0.tgz","fileCount":293,"integrity":"sha512-6nTj4lsAXAvV+FdZYvmmp6BhSnI8gM0PY3ERTL1mluEqHOQOiyLD+9C9tZr8WjKD8dUU/Qf09WWuLaI3O/g4Sw==","signatures":[{"sig":"MEQCIBXqA82JMLgYHgIQG3eowknFN6cfDv52T3/rAaL5Rd72AiBRct2rV8fS81reIvRKwNFJODaqL1VX6+bbMEZUC4Slow==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39061227,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkSPW6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqFOw/5AZ0kYYjX9kGfr/4mAzS5bdw8DxfiwsPN/ONFSDzgkCOKpyEd\r\nMcwGVttnyvsy7mR5/fihDOZa8Ejt9kBF0rNDBjeh/b0MTlVWC94EYgVSCJ/u\r\nv6pF2s2C6fy/03T2ilnL/fZrA4IMQjOqHGlDAfGNdj+dCs14jFcXOvASgcE1\r\ndxp3oPG7IjQQLMn7JsUbSUJqziPmoypvvrnpmOFlvIH8BRy2EsG+6YpHBISt\r\nNMG8fg1f+HRJNPvCkgNhpp8XDH4tkHK9TGQOesgtbAcf8wmKfBvcGs6yGBXD\r\nwDoDzWLrmbUpKkQiz5UTCuPhZlUBMsPfmI4RuUzUSSmBZpsOfStNIXyvi/Nx\r\nk6frJxE51bIXvxKsPfq5AF8kedaGcyrlZBTy4ZCIV95PTZHSni2yq/iGQciB\r\njHTYVO4TlEkTq9O5H/XzY+EF8vIfkOddgAwF4B6pInNDSwfpIJzhjJdYnpCi\r\nlnOFFslxHBXIIbeBaivQI/ndiypsww/U2kulY2FczgB9J3gXOEkQPBiilULG\r\nhsDV7PjYGU2kKU/lU+clJQ7byJQ65kCtEGuNIyDv1IHNYTayVqOVuieLB0Zp\r\nDFsjZQc63qsst/c3X/FXeanhf3x7cH208TeskQND7RImR2LsgysZoTXdRnlA\r\nw+NrzjxJLlLZyft7DkoxNhO6ZKYoehB8SDY=\r\n=eIJO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"ee75dba94054daa919815c5d59f883f4422f3b62","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.3.0","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.3.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.3.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.135","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.3.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.3.0_1682503098230_0.7112787606670967","host":"s3://npm-registry-packages"}},"8.3.1":{"name":"streamr-client","version":"8.3.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.3.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"d8b88943322f087430a05fafd07f62ffd5ee1ac3","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.3.1.tgz","fileCount":293,"integrity":"sha512-guQWUO5W47DrE7BSDCdXLwM3osYpxNvDGf09QGe0UaXCT7ZsVHzqNRRMlKYUXhGWNQtogxennwRQCHJOmLNrzA==","signatures":[{"sig":"MEUCIQDShlJBwqcmdaJWldv+aCkSnvqeTN5SRt6hjlpMTBnEYQIgTWaAlGoBsiIK9arAqrt8xWiMrz0RTzxfHr9nItlSGbs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39003868,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkUlQFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqw2g/8CzPxYSws9oQeidU9jjzRcLvwmoSoT0TSnDsmP1bBjiRrKVAN\r\nbL3Y+k8L4Z+mLBT9g7GPH190drjGQaLZz1sLd0NH9jQCo/xbgjxeJEjqwRJR\r\nE8rTRQ+/8edR2YckB35KXAQaEjbhqXDD70N/C/xCD4rih3VI5hMOmgKpib+u\r\nIuK+23RvL3yQRaOvHIpWrJl+TEs6rHx3T5XPh6d0rLe3jUZ7PVYyMaF+ji9z\r\nFfckaC+RWY4am8352JXuOlZJ+IIy6uhVw10jkZAr0ZVytK/i0A1dyIVxUf0l\r\n7FLZfYHkGrcHt+EpWleXgAXpTJUr9iR6RZN/k7NIZD0eg1wx8XphrksQYIwk\r\nYLbdfD5dQ58ln1JARdedymprW0Z4GRj16pfp6wlfL1B0cKNSTEd+f2jCaWcx\r\nDoCaqRq+ye9qQx0cLNz1ypjhmfoKf0XzqPctqiPXQ93wW26H1JrRTTsUKJIC\r\nQjUKPR+1YMAfErlKM7+kLH9iqiyqNGTu1HDSDJViD3fLeFoLbWUiadO2ArQC\r\nieQ3ejwpbj3e5nFQv41E6StCgnep7ALvLTJZ6HJWVMXcSIXFnqMeQX2Bf/sx\r\n49UeVpCJGjFtkQWdEDeaOsypZXLA1w1w9gc2YUKyW6AjILj9YRpYphWGU6D2\r\nCQrwMPAQqoENheFFycyxCAUmFbrfFDWNUVw=\r\n=TPpt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"594c7b151b79a953c2913efe2c1b01b4c8867025","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.3.1","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.3.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.3.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.135","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.3.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.3.1_1683117060804_0.37071133597617023","host":"s3://npm-registry-packages"}},"8.4.0":{"name":"streamr-client","version":"8.4.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.4.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"9407005cf4ceaf15e9bc78b6667caafa2ff6bb0b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.4.0.tgz","fileCount":284,"integrity":"sha512-uPj0KiZIJbSdsikfSCy3pTUE0eUyTkmLGZXdNk7a/4nN7lpiGQeGsf7FgigE+u8XvDmMyIQH4EsDGJGNnHubuw==","signatures":[{"sig":"MEQCIEtqHG97Yq7OEloaQcNvKlZ5fJzsnS1Ak9ogmqg2Q4PkAiBaeAoCxG1b8Y/gcCYBxU/SropJt33GAGcx82g/pTEhmw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31951607},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"887447d19072fc1ad034a1f41a4b990e84da5216","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.4.0","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.4.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.4.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.161","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.4.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.4.0_1683631426153_0.6061632361298817","host":"s3://npm-registry-packages"}},"8.5.0":{"name":"streamr-client","version":"8.5.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"8d6408731001b39a0923a16a7d962395205b1c8b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.0.tgz","fileCount":284,"integrity":"sha512-0z5jJjBxollWv4U1H7qpovRuLdDVmjU9+2sAqF7TKg+gwfHoRkFCtjY0E5a99JKGF5TV7B/SqtoG/BmlIYmivQ==","signatures":[{"sig":"MEQCIEbn2NWs/+2dbr2mGxNaylmP1Rii1UfmIVfrZN1HutkRAiAjuOrXgHjLMuC84IeO3zILZ4ThbYixkypHNMJxEtqqDw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32000302},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"5df870cba427226f87ebecb077d55928a0c812c5","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.5.0","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.161","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.0_1683710896279_0.11993228130181333","host":"s3://npm-registry-packages"}},"8.5.0-nolit":{"name":"streamr-client","version":"8.5.0-nolit","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.0-nolit","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"0aa6e91b3288fc6bbf006a48052541b2c0f2241e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.0-nolit.tgz","fileCount":284,"integrity":"sha512-i/HaxAUK41IaABnzdBlSmf7mJUc1HmScuklpNfS43oJm0BWRahrIYOzSIPmeEn0pA+46psXNkyjJC9fakRpY0Q==","signatures":[{"sig":"MEQCIF5/d6aR0oUZ523+vElNMQZQDCygbQLm36V/9eBoqvvMAiAyqF1ZZ9RWi3VtQvxAg3gKhKvQJDYxQHTa3koirhw7fw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24960640},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"5df870cba427226f87ebecb077d55928a0c812c5","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.5.0","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.161","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.0-nolit_1684241430122_0.7022474626428419","host":"s3://npm-registry-packages"}},"8.5.0-nolit.1":{"name":"streamr-client","version":"8.5.0-nolit.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.0-nolit.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"e54e9c37abf593edbdfbbdd963b49662f7d08c71","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.0-nolit.1.tgz","fileCount":284,"integrity":"sha512-MPlpMvszEXsNB+hIxw9c9nTGnVlegMVL20euR+ja1+eny84tserDpM+1zARnzZGbxeGQmxvhS0IACPMBLVfH2w==","signatures":[{"sig":"MEUCIQDv+tIfz9oOzZmm2n6tKbFIZLYK83f2TasklbnnYziavwIgYFVjI3vo6XNnTLXKEmija2t5qoop8niw15sCwY2gnYA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23216784},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"5df870cba427226f87ebecb077d55928a0c812c5","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.5.0","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.0","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","strict-event-emitter-types":"^2.0.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.161","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.0-nolit.1_1684242211138_0.5442452241655606","host":"s3://npm-registry-packages"}},"8.5.1":{"name":"streamr-client","version":"8.5.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"758bc5f01dbb75fc3f6d448efe026d4202878526","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.1.tgz","fileCount":272,"integrity":"sha512-YqBu8GhweLdB7FclVkL3hDba6qXGK+gfUqE6o7/IlGmPFGTVh3jwVLjDtIZ4Gey5ShgrNDNqc5gob/QziKoK0g==","signatures":[{"sig":"MEUCIQClDjp2JdV8uM8uyoF3+ZKGj79G+24c0wPseHRNqkQAQQIgMwOJx6GXIsNu1AM3PYhMTh76FrNqvCzi9tsR4SSsZ0A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31778529},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"738ef84b9253b0d1095904adca7618caebeaba47","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.5.1","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.1","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@ethersproject/transactions":"^5.5.0","@lit-protocol/lit-node-client":"2.1.161","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","ts-essentials":"^9.3.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.1_1685352187212_0.4759502257277344","host":"s3://npm-registry-packages"}},"8.5.2":{"name":"streamr-client","version":"8.5.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"4149d3ed3cc0e160a72cbc8dc89e9d9ae1eb971b","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.2.tgz","fileCount":272,"integrity":"sha512-qG+QtuNdr8nN9HlpP+KGlFxLgE01ahw5ppDKwZIKwTOIQGpSccZCNeDWqiuuyG+jd5NEVPDobjr+s6Rz6ERHTA==","signatures":[{"sig":"MEUCICNNFCaIwDoT6EnPlM9hYFLXKcc/heAEM7DC0RsHQjL/AiEA3N2iQuHP38LgQAbft984G652AjTQGYWMZ02X8Go4wUA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29391928},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"7dd47ef057f3439064c824f56f788b21e4c38d7f","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","ts-essentials":"^9.3.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.5.2","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.2","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.11","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.2_1685523161898_0.8200383661953607","host":"s3://npm-registry-packages"}},"8.5.3":{"name":"streamr-client","version":"8.5.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"9577378a0bbf2c93ad32bc22b954929f8e26d1ff","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.3.tgz","fileCount":278,"integrity":"sha512-/SePbhyX2HxiE5xgpAMyz6ro0cJDV5R2LzY6vqD1eYQE41nIx9L+auU3P4gbpmOZyJXQRp2JfDnzpJKGaesNKQ==","signatures":[{"sig":"MEUCIE/0GfQ4jsfU9SNrnhqzwh9/TL9/d4I8f0UMeUNEWefVAiEA3J/V53FZbN2z477qtTgAjJ/s2eQCwwMTftv8g9kn3U8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29384959},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"cd42c4f48df3ca6a2b3e88bfaf579f57f7c29210","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.4","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.19.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","ts-essentials":"^9.3.0","@babel/runtime":"^7.16.3","@streamr/utils":"8.5.3","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.3","@babel/runtime-corejs3":"^7.16.3","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.11","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.4","webpack":"^5.64.1","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.16.0","@types/heap":"^0.2.28","@types/uuid":"^9.0.1","webpack-cli":"^5.0.1","babel-loader":"^9.1.2","chromedriver":"^112.0.0","concurrently":"^8.0.1","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.16.4","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.5.0","@babel/preset-typescript":"^7.16.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.16.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.16.4","@babel/plugin-transform-modules-commonjs":"^7.16.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.3_1686136810630_0.9986319400692045","host":"s3://npm-registry-packages"}},"8.5.4":{"name":"streamr-client","version":"8.5.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"3cbd913fbb9d9bcb3c75bcb2907033973fcb65b8","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.4.tgz","fileCount":269,"integrity":"sha512-IJrDHulzbyrp/u5PwBKtxN5AV4g0daVcdu9FtE546klKSqRuHE0jwcMnGpxNr0bolevqlvnIiZndIDCqKVmlIg==","signatures":[{"sig":"MEUCIHkMnHlzVTm7jPpX7/kK9lpHcxzncVQjCSgQFkJFXBfGAiEAvbZonRLR14H5WVKIf4uZWktdUoeVHZKTSrV8VNLmM+8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29292830},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"0e64bb1451824c240deb3ef21cee1795fb794683","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"ajv":"^8.8.2","idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.31.0","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.6.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.6","p-throttle":"4.1.1","ajv-formats":"^2.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","ts-essentials":"^9.3.0","@babel/runtime":"^7.22.5","@streamr/utils":"8.5.4","utf-8-validate":"^6.0.3","readable-stream":"^4.3.0","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.4","@babel/runtime-corejs3":"^7.22.5","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.24","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.8","webpack":"^5.87.0","benchmark":"^2.1.4","ts-loader":"^9.3.1","weak-napi":"^2.0.2","nightwatch":"^2.6.20","@babel/core":"^7.22.5","@types/heap":"^0.2.28","@types/uuid":"^9.0.2","webpack-cli":"^5.1.4","babel-loader":"^9.1.2","chromedriver":"^113.0.0","concurrently":"^8.2.0","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.22.5","@types/node-fetch":"^2.5.12","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.4","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.0","@babel/preset-typescript":"^7.22.5","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.5","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.22.5","@babel/plugin-transform-modules-commonjs":"^7.22.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.4_1687782632864_0.6766760397559033","host":"s3://npm-registry-packages"}},"8.5.5":{"name":"streamr-client","version":"8.5.5","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.5","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"8169b5a2e477c8b76c39322fb10dc6a57241d378","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.5.tgz","fileCount":269,"integrity":"sha512-FtGXkUr0oHkgQDqi7mGc8ZzOxlmU3FSqxoTgwFVIsmsP+UT9xfKZ61emgcwNaFv0pSSysv993mw6iLZVXmHlVw==","signatures":[{"sig":"MEYCIQC125miB1t6icSlS4g1RHejYcmXcWcVRuH6H2Edj8EKKAIhAJoy+l5o2y18QofaJzIr5YdFfnueVchHQdwTaMcAsSgD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":27824449},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"8c172c2f49ad65aa37a0fd5ffff7d0d9c402a889","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.7.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.31.0","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.12","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","ts-essentials":"^9.3.0","@babel/runtime":"^7.22.5","@streamr/utils":"8.5.5","utf-8-validate":"^6.0.3","readable-stream":"^4.4.1","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.5","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.5","@babel/runtime-corejs3":"^7.22.5","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.36","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.8","webpack":"^5.88.1","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.0.1","@babel/core":"^7.22.5","@types/heap":"^0.2.28","@types/uuid":"^9.0.2","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.2","chromedriver":"^113.0.0","concurrently":"^8.2.0","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.22.5","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.5","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.0","@babel/preset-typescript":"^7.22.5","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.5","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.22.5","@babel/plugin-transform-modules-commonjs":"^7.22.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.5_1688649478985_0.6134271681967376","host":"s3://npm-registry-packages"}},"8.5.5-nolit.1":{"name":"streamr-client","version":"8.5.5-nolit.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@8.5.5-nolit.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"c82c83a3ac1a4a5131cc24c7c094733ca5f195ac","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-8.5.5-nolit.1.tgz","fileCount":269,"integrity":"sha512-jmyDap62EKK7XD5hnLS0MHUlwPYD9/4Md5g4jGZ/w5Z0zXjuccV3anM1HRE5ODY1LoL8beVlY5rYUPAN9xFD6w==","signatures":[{"sig":"MEYCIQCZ8FfyDSJ8I7kuZamkFlPeNLlM6siloMAXC+r2BRkzhQIhAJAoBsGOfA7JU/vv6/MIdWbh9PWT5fB8t1e3RS1/m4Rm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21440655},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"8c172c2f49ad65aa37a0fd5ffff7d0d9c402a889","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.7.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"idb":"^7.1.1","heap":"^0.2.6","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^4.0.23","core-js":"^3.31.0","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.6.12","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","eventemitter3":"^5.0.0","ts-essentials":"^9.3.0","@babel/runtime":"^7.22.5","@streamr/utils":"8.5.5","utf-8-validate":"^6.0.3","readable-stream":"^4.4.1","reflect-metadata":"^0.1.13","@streamr/protocol":"8.5.5","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@streamr/network-node":"8.5.5","@babel/runtime-corejs3":"^7.22.5","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.36","@ethersproject/transactions":"^5.5.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.8","webpack":"^5.88.1","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.0.1","@babel/core":"^7.22.5","@types/heap":"^0.2.28","@types/uuid":"^9.0.2","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.2","chromedriver":"^113.0.0","concurrently":"^8.2.0","@types/lodash":"^4.14.175","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.22.5","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","@streamr/test-utils":"8.5.5","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.25.3","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.0","@babel/preset-typescript":"^7.22.5","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.5","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.22.5","@babel/plugin-transform-modules-commonjs":"^7.22.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_8.5.5-nolit.1_1688650485744_0.008803604794298758","host":"s3://npm-registry-packages"}},"0.0.1-tatum.0":{"name":"streamr-client","version":"0.0.1-tatum.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"67dae2f73b0636c787705ead5210c27e1340dbee","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.0.tgz","fileCount":266,"integrity":"sha512-/bltF4D/Q5KfDeFSD87i3+igYPlo9J1lQ2Q5S+/EeW4bQS6Eess8e1AbKwWBCGhQNb4WE7GIR4XQRmSOQpemNQ==","signatures":[{"sig":"MEYCIQC1EbMR3mruW3bhUAi5bxqnms1UwZyroc6PxoMpl0TVlwIhAP/nndbrtK8AGUkJbf4mvzfR37k48YJu4YOQQrCRw+MT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36433486},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"f2b977b7ff8efc31b4f897325919ddb87f762fe5","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.16.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.32.0","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^6.0.1","secp256k1":"^5.0.0","node-fetch":"^2.6.13","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.0","eventemitter3":"^5.0.0","ts-essentials":"^9.3.0","@babel/runtime":"^7.22.10","@streamr/utils":"0.0.1-tatum.0","@streamr/config":"^4.0.1","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.22.10","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.47","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.24.8","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.1.2","@babel/core":"^7.22.10","@types/heap":"^0.2.28","@types/uuid":"^9.0.2","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^115.0.1","concurrently":"^8.2.0","@jest/globals":"^29.5.0","@types/lodash":"^4.14.197","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.22.10","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.0","@babel/preset-typescript":"^7.22.5","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.10","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.22.10","@babel/plugin-transform-modules-commonjs":"^7.22.5","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.0_1692711198840_0.5417607950606136","host":"s3://npm-registry-packages"}},"0.0.1-tatum.1":{"name":"streamr-client","version":"0.0.1-tatum.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"e942c05ee29d8e80b320d94163ce50695afb712e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.1.tgz","fileCount":269,"integrity":"sha512-20GzuSFyvj6zkG0kiFxflfkUcZd8kc4e+36gBpa0Xysf61QLpD0RCjGcpOpIEzpMIE6KSui+9PyfSP8z2+N1fQ==","signatures":[{"sig":"MEQCIGq9+1PqtQApPsquM72Q7pMtXfitQLqzPrZTpsdBpel/AiBceT4lNZSwUKZDGnaGaSz2p1tMtym+oOoIv8QwrYTPDQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36625936},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"9d3e666be9fb7cdf329c4e0630fca0fe4770d26a","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.32.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.1","eventemitter3":"^5.0.0","ts-essentials":"^9.4.0","@babel/runtime":"^7.22.15","@streamr/utils":"0.0.1-tatum.1","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.5","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.22.15","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.54","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.1","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.1","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.1.3","@babel/core":"^7.22.17","@types/heap":"^0.2.28","@types/uuid":"^9.0.3","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^116.0.0","concurrently":"^8.2.1","@jest/globals":"^29.5.0","@types/lodash":"^4.14.198","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.22.15","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.22.15","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.15","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.22.15","@babel/plugin-transform-modules-commonjs":"^7.22.15","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.1_1695043515307_0.6351315741150485","host":"s3://npm-registry-packages"}},"0.0.1-tatum.2":{"name":"streamr-client","version":"0.0.1-tatum.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"8438fe2cd09a3bda6a4c186cad66a765f53516d6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.2.tgz","fileCount":266,"integrity":"sha512-R6mhmdaloMwhJ+LnQx1q4gmPEJrTSTHNm5aZ8JRWdnhsveueLlxkXyYSxRmRwF4b1sJ5i4VU1mMojkm5wd7C8A==","signatures":[{"sig":"MEYCIQCH96IUHtl769lr0VVeMJIXMiWQS0UPaG1RDJFcwNgjuAIhAJkXveV+SNqy4Coo6SWwaapIY7sSqSeyoB7uTN7CPTQq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36675464},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"4e224eb95033d9f939ea0e227a1cf5477634048d","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.0","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.32.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.2","eventemitter3":"^5.0.0","ts-essentials":"^9.4.0","@babel/runtime":"^7.22.15","@streamr/utils":"0.0.1-tatum.2","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.5","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.22.15","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.54","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.2","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.1","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.1.3","@babel/core":"^7.22.17","@types/heap":"^0.2.28","@types/uuid":"^9.0.3","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^116.0.0","concurrently":"^8.2.1","@jest/globals":"^29.5.0","@types/lodash":"^4.14.198","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.3","@babel/preset-env":"^7.22.15","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.22.15","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.15","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.22.15","@babel/plugin-transform-modules-commonjs":"^7.22.15","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.2_1695215428833_0.8503038338934474","host":"s3://npm-registry-packages"}},"0.0.1-tatum.3":{"name":"streamr-client","version":"0.0.1-tatum.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"561a0b54cf7e3293b0cfabff76a52bf89bf40839","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.3.tgz","fileCount":266,"integrity":"sha512-RBVf3iGW54Y8eD+itWuXNhMA6XkvklPZnRvWd4ZRzStqL+onH3JMT4V12MGV8xp7RQ1C7CTIp8OMsT9Lb+cIoQ==","signatures":[{"sig":"MEUCIQDUmoKHEgCdaFisgV1lLnfwHox2V6LzELn06KiZbV3qCwIgffozGrS+sRPgAIfn2aLNBc5AcDqgbqtfE2cguijNXUc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36651286},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"c553026b92a9536a3425be15e32ac44239b2efce","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"8.19.2","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.1","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.32.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.5","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.3","eventemitter3":"^5.0.0","ts-essentials":"^9.4.0","@babel/runtime":"^7.23.1","@streamr/utils":"0.0.1-tatum.3","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.8","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.1","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.54","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.3","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.1","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.1.3","@babel/core":"^7.23.0","@types/heap":"^0.2.32","@types/uuid":"^9.0.4","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^116.0.0","concurrently":"^8.2.1","@jest/globals":"^29.5.0","@types/lodash":"^4.14.199","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.4","@babel/preset-env":"^7.22.20","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.15","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.0","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.3_1695992021788_0.5579772249652146","host":"s3://npm-registry-packages"}},"0.0.1-tatum.4":{"name":"streamr-client","version":"0.0.1-tatum.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"ed31f754df09afa58d98327ddd9e3a99bffe3a63","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.4.tgz","fileCount":266,"integrity":"sha512-bpirIx6bmRJ36uI9BAXm606FtX0vhNktVxw9W4XpezKmOtjVh2jvWWvBTn/p07eGpXet8LfOX5zeVM8W/gOsfw==","signatures":[{"sig":"MEYCIQDrRvOSPv4U6/QkYe8sX/e57xcnjKN6ZiRADwzR0ESrggIhANP3KZM4XUsFe5rHlm7wh5DNYCHB0G8D3WkdYaq61qhS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36652102},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"1c5381712923e40f43246fbcf7d2774dcd3b1d76","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.32.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.4","eventemitter3":"^5.0.0","ts-essentials":"^9.4.0","@babel/runtime":"^7.23.1","@streamr/utils":"0.0.1-tatum.4","@streamr/config":"^4.0.8","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.1","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.54","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.4","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.1","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.4.4","weak-napi":"^2.0.2","nightwatch":"^3.1.3","@babel/core":"^7.23.0","@types/heap":"^0.2.32","@types/uuid":"^9.0.4","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^116.0.0","concurrently":"^8.2.1","@jest/globals":"^29.5.0","@types/lodash":"^4.14.199","@types/split2":"^4.2.0","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.4","@babel/preset-env":"^7.22.20","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.4","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.15","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.0","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.4_1696331793605_0.988234927150607","host":"s3://npm-registry-packages"}},"0.0.1-tatum.5":{"name":"streamr-client","version":"0.0.1-tatum.5","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.5","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"34ed86638865fe2d032c11c5d542a932306e0b12","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.5.tgz","fileCount":266,"integrity":"sha512-R4xt8UDiRU74pqwvZJiX5M2JjpDswW08q9l/OJBrnzkZ34fDoQtGE+mhyphacsbwn0loKoNbnqDBw/Ybc4OPfw==","signatures":[{"sig":"MEQCIGfDg+Y/A6+PRJ0/GO3lHGOUpugPHmeXm1Z9T4XvPpTcAiA8eVQpSj8UGMkd/8cTguJsjhQ4jp79osNdgIg1O0r31Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36658077},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"92669a9d48e1e83f2668aa07ad9e9d3f10b5919a","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.33.0","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.5","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.1","@streamr/utils":"0.0.1-tatum.5","@streamr/config":"^4.0.9","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.5","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.1","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.5","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.2","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.2.1","@babel/core":"^7.23.0","@types/heap":"^0.2.32","@types/uuid":"^9.0.5","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^116.0.0","concurrently":"^8.2.1","@jest/globals":"^29.5.0","@types/lodash":"^4.14.199","@types/split2":"^4.2.1","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.4","@babel/preset-env":"^7.22.20","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.5","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.15","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.0","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.5_1697034743420_0.515808409680619","host":"s3://npm-registry-packages"}},"0.0.1-tatum.6":{"name":"streamr-client","version":"0.0.1-tatum.6","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.6","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"8f1f1e6d3d932c18f4998f75f197e7330514850a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.6.tgz","fileCount":266,"integrity":"sha512-Byx0VnWLacOm9W+kiyOkK+lo+EbQ61N6HPoUGXle8VpuJtn+HKuUrdZt85nT/IYqImzqJm9eBSh7j4OgQCkRyA==","signatures":[{"sig":"MEUCIQD/byCjzPe697RBx7luc1Iz2VfB+2QS3aELMaFeLRwbBQIgcJ4noMIVPV2b/i+hCnGsREI9XXFWhgKq7+WIicyiJhQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36645796},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"a6ccb230d9196415956fac7a918700759a779568","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.33.0","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.6","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.1","@streamr/utils":"0.0.1-tatum.6","@streamr/config":"^4.0.9","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.6","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.1","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.6","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.2","webpack":"^5.88.2","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.2.1","@babel/core":"^7.23.0","@types/heap":"^0.2.32","@types/uuid":"^9.0.5","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^116.0.0","concurrently":"^8.2.1","@jest/globals":"^29.5.0","@types/lodash":"^4.14.199","@types/split2":"^4.2.1","webpack-merge":"^5.8.0","@types/secp256k1":"^4.0.4","@babel/preset-env":"^7.22.20","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.6","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.28.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.0","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.22.15","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.0","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.5","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.6_1697205328707_0.2609373019165131","host":"s3://npm-registry-packages"}},"0.0.1-tatum.7":{"name":"streamr-client","version":"0.0.1-tatum.7","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.7","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"c506f6fd805691f14c750edf08648f5838628bb6","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.7.tgz","fileCount":266,"integrity":"sha512-j6rx6nSk/eGifNO245u0feP+gjIrwTwW70uM3/ANRDEolsZToZRixvGPQDGZJPdqK8BYcCfqkC0IjFbXAv6OMQ==","signatures":[{"sig":"MEUCIGWhlHUqVqOWhu7/TSHHv9Ph4R8yIMcEqehXtRBsKWwQAiEAuz6EioAPriMoiqU4ICKC99DRr9cfgyV3fyzqefGyEk8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36669468},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"05e780eebc1d5f2d1fbc40eddad3677de3db11d9","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.33.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.7","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"0.0.1-tatum.7","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.11","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.7","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.7","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.2.1","@babel/core":"^7.23.2","@types/heap":"^0.2.33","@types/uuid":"^9.0.6","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^117.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.200","@types/split2":"^4.2.2","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.5","@babel/preset-env":"^7.23.2","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.7","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.2","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.2","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.2","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.7_1698757468435_0.49663274065124297","host":"s3://npm-registry-packages"}},"0.0.1-tatum.8":{"name":"streamr-client","version":"0.0.1-tatum.8","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@0.0.1-tatum.8","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"c5c004022f3ba16788c30f1d6ae02d255e82b994","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-0.0.1-tatum.8.tgz","fileCount":266,"integrity":"sha512-jWBPm6y3q8bNlOt3mOaJQk3dB3faO4vILiTvLr6YHfiyQJWm0p2Kys7GymD9c5JMVmYg2drwLKNUeiWlk+tw3A==","signatures":[{"sig":"MEQCIGvs/OPkWmCzbtH0218GKPb8jgGR5+LU5GhfT7ureoQeAiBcIATii5Trt5WRB+Tds9RE49Bdw0gXv6OaQmuHtU6Ibw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36642843},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"d9b0569d1094443e9644e74817d682ae33810060","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.33.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"0.0.1-tatum.8","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"0.0.1-tatum.8","@streamr/config":"^4.0.12","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"0.0.1-tatum.8","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"0.0.1-tatum.8","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.2.1","@babel/core":"^7.23.2","@types/heap":"^0.2.33","@types/uuid":"^9.0.6","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^117.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.200","@types/split2":"^4.2.2","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.5","@babel/preset-env":"^7.23.2","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"0.0.1-tatum.8","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.2","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.2","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.2","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_0.0.1-tatum.8_1698870309117_0.09263244171272444","host":"s3://npm-registry-packages"}},"100.0.0-pretestnet.0":{"name":"streamr-client","version":"100.0.0-pretestnet.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-pretestnet.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"43239ef130680af30d0b86eadab9fd07dc4b3c79","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-pretestnet.0.tgz","fileCount":266,"integrity":"sha512-LYq7I/DC03K2iHWMNDnEb8gVwpx14bOEU5d0P1Cye5uVTBJDEkdsqocQDzK0644NZ1EG/OS60srmQ4zcMouJ5A==","signatures":[{"sig":"MEUCIQC/vPT26H1G2fXK5eJosVOvjdBe7z2hVvCw+qv2Q/OK7QIgCK+Y45iILCl/2i6y4upmPul+A1Sowfhl9TCnKAaEgJc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36643843},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"a3e8d095a37b3fb4a4ea18cca78506446d810061","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.33.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-pretestnet.0","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"100.0.0-pretestnet.0","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.12","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-pretestnet.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-pretestnet.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.2.1","@babel/core":"^7.23.2","@types/heap":"^0.2.33","@types/uuid":"^9.0.6","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^117.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.200","@types/split2":"^4.2.2","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.5","@babel/preset-env":"^7.23.2","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-pretestnet.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.2","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.2","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.2","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-pretestnet.0_1698932024686_0.418725317731345","host":"s3://npm-registry-packages"}},"100.0.0-pretestnet.2":{"name":"streamr-client","version":"100.0.0-pretestnet.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-pretestnet.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"cf7fdfc9ab0eb64f86f0dc98e09cbb29958a069e","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-pretestnet.2.tgz","fileCount":266,"integrity":"sha512-1n/my3Kf15QPQ4/9bz0FVFGDXYlIIKcfdo+8x0GBQf1B1cNfn+uP8wCZFyyvvM3elpPtgoMXrmVRQBQ46ecn9A==","signatures":[{"sig":"MEUCIQD0RCOZiDSw3bbGBpIRGABspdVbYgI1xG9Ambm/JwRPVwIgAoc4BsY59/mZJau1kOv2LRbyHL+mZ3QaCHjGtxXu1RQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36645761},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"88b4559daa7933b7c36fee100e4af13c157eb569","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.0.1","core-js":"^3.33.1","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-pretestnet.2","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"100.0.0-pretestnet.2","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.12","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-pretestnet.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-pretestnet.2","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.2.1","@babel/core":"^7.23.2","@types/heap":"^0.2.33","@types/uuid":"^9.0.6","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^117.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.200","@types/split2":"^4.2.2","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.5","@babel/preset-env":"^7.23.2","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-pretestnet.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.2","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.2","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.2","@babel/plugin-transform-modules-commonjs":"^7.23.0","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-pretestnet.2_1699536329753_0.684265362017668","host":"s3://npm-registry-packages"}},"100.0.0-pretestnet.3":{"name":"streamr-client","version":"100.0.0-pretestnet.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-pretestnet.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"4cccacec2ac241cf53e5e884d29f8f23434abf05","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-pretestnet.3.tgz","fileCount":266,"integrity":"sha512-OuMK8at86ZowDDSyXVamEx0afC+FSIReNcZFPyw1fL1HcQeQKhiUGMW/4G85JMy1v+qeMhpdIzc5gXlnCbZSsA==","signatures":[{"sig":"MEUCIQCciF5wZk8/Uo8uYFfSywzmwNR1moYOndS4WRFXVPtnpwIgNK1YslydN3GSoVujrHF137XqmVcgCLG4/HBdFas/vTw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36852136},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"cdbf514dc5b8fe556e683156e2e19c97d4ab9df8","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-pretestnet.3","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"100.0.0-pretestnet.3","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.13","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-pretestnet.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-pretestnet.3","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.3.0","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^117.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-pretestnet.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.3","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-pretestnet.3_1700063463522_0.9424348384595038","host":"s3://npm-registry-packages"}},"100.0.0-pretestnet.4":{"name":"streamr-client","version":"100.0.0-pretestnet.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-pretestnet.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"85968d89da9d96d59e34e5d6307352ea304039de","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-pretestnet.4.tgz","fileCount":266,"integrity":"sha512-AQ3SgJsxsl9Y77Rnionskud8MOa6VcVFkCYJORQoeG/0EY+NOSHW/AVzUAs3EDBuToxcY5aLBPx3GQT1AJ24zg==","signatures":[{"sig":"MEQCIFpfZmu/6TF26Ej9LOrdIRqmPze5UOAJ1efqaWWyx954AiAVzU2mIuGUPzeadJxwGVgGAhmsijYzX1gBr1Hy4ueoxg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36862735},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"4bb53dfb1bab5d0628ec2d032d2067b2c1a057f7","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-pretestnet.4","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"100.0.0-pretestnet.4","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.13","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-pretestnet.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-pretestnet.4","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.3.0","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-pretestnet.4","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.3","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-pretestnet.4_1700502277541_0.6265969955807495","host":"s3://npm-registry-packages"}},"100.0.0-pretestnet.6":{"name":"streamr-client","version":"100.0.0-pretestnet.6","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-pretestnet.6","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"3fc1ed259b70543e111ebe1e1736cafd9405c474","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-pretestnet.6.tgz","fileCount":266,"integrity":"sha512-kdguy+mmnUPlrLCFc0I6iRr3b7gkZNc+5u4Xz7og6hBs+crdcDAx1BNzvFsAaAzuiTD2icNvsaTGMwQxjToYCg==","signatures":[{"sig":"MEYCIQDI4FGgkx+Udu8ypObiA9wwnbio835lGW/ZDzMR2XADcwIhAOw4+N7GcXA1N2HPXyUgZHfjCTCqFL7ceTnscy9KOgP/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36862740},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"6a21b12cacfd05b28489290c42ec44047f4fe818","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.2","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-pretestnet.6","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.2","@streamr/utils":"100.0.0-pretestnet.6","utf-8-validate":"^6.0.3","@streamr/config":"^4.0.13","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-pretestnet.6","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.2","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-pretestnet.6","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.0","weak-napi":"^2.0.2","nightwatch":"^3.3.0","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-pretestnet.6","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.9.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.3","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-pretestnet.6_1700671007461_0.7094413394822476","host":"s3://npm-registry-packages"}},"100.0.0-testnet-one.0":{"name":"streamr-client","version":"100.0.0-testnet-one.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-one.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"de902b566e69c163bcf48c785ff606789b9b917a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-one.0.tgz","fileCount":266,"integrity":"sha512-DVBYnieOnYWnWwG89ZVctZsLqBcHax1uQfSvixTREliXd/X5ol/QxVq+TUkZw7Atjlq5JJkTdQXCzu3r+6Plmw==","signatures":[{"sig":"MEUCIQCv8RRcAXQYS0Sxv8cc0tK8gSS03x8DFPqHw2B76SO6sAIgZfmpdb+tnUwyXK8zNG4mMwm0uBDNE+hlK2yeMWuG+r4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36901640},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"52bfba4ba059963882a65f2c2fe600bfb5149630","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.6.6","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.12.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","bufferutil":"^4.0.8","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-one.0","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-one.0","utf-8-validate":"^6.0.3","@streamr/config":"^5.0.1","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-one.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-one.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-one.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-one.0_1701108467707_0.517954464488676","host":"s3://npm-registry-packages"}},"100.0.0-testnet-one.1":{"name":"streamr-client","version":"100.0.0-testnet-one.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-one.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"a1380017092f07388bee0dc48870649f9b41ecb4","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-one.1.tgz","fileCount":269,"integrity":"sha512-BnbIoSJ82V5vxmOWIS3Qsk2ZJx/iueBQD9+17cIM7qaOAl5oweKkEeKxXhqkaXcFcZWW68vKvQnzPJi9f0Fw3A==","signatures":[{"sig":"MEUCIQCk3eyWN2zQoDofKoPC2Mj7eTeoXNMKA1YEbtA+KUCu0wIgfOCINPop4rUQ4UoEcMtbJIGaXe+gkLxabxzkemveERc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37018518},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"e9e9e09905e0487e82e38a69db343610b79d1c09","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-one.1","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-one.1","@streamr/config":"^5.0.1","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-one.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-one.1","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-one.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-one.1_1701693314904_0.8177882369172671","host":"s3://npm-registry-packages"}},"100.0.0-testnet-one.2":{"name":"streamr-client","version":"100.0.0-testnet-one.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-one.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"0ccb6cb65f44c594c1b8e38c961c073ed0ad5f85","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-one.2.tgz","fileCount":269,"integrity":"sha512-2wJ3LDSM9qk/8yXJ0vNLPqNxa1m+FeaZHrV4Oimq4UFO27HLZVjkOUj97/zmPbRPRhmTV1bZY3ueCdBS2QVr5g==","signatures":[{"sig":"MEQCIHTAOi9+97AnnJ6UoqppTjEm7kjaZfV97NWKU3mv+sxkAiBuGOJnas/B17Y292OHaiXn00k+21gAAPVSfchxWX8IEw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37027562},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"3c74af4597de3cb32d1078493b349dcfd112f637","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-one.2","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-one.2","@streamr/config":"^5.0.1","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-one.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-one.2","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-one.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-one.2_1701797074682_0.9733835759535796","host":"s3://npm-registry-packages"}},"100.0.0-testnet-one.3":{"name":"streamr-client","version":"100.0.0-testnet-one.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-one.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"51926ab90009eb30154d996f9a2ae596e600d33d","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-one.3.tgz","fileCount":269,"integrity":"sha512-du2r+ncO2UqyFlNWZkd9CoSihyYkiUmv8wEagKSrHGmG9yyXCL+v0VW7p3klt1W3odpE70+o+2DIVviZ/k2liw==","signatures":[{"sig":"MEQCIFRGQj8sFjq/hrCdd4rn87G3oCDrSxdCJdnXxwf8Ly5aAiAEfaGCyKsewW+4NpzImLBjW8P1Dp7PvVNF+EZ/gJdzlA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37027516},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"d19e7ba25f93bc71afdfb600d3e961796409219e","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-one.3","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-one.3","@streamr/config":"^5.0.1","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-one.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-one.3","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-one.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-one.3_1701964642700_0.12528757351888342","host":"s3://npm-registry-packages"}},"100.0.0-testnet-one.4":{"name":"streamr-client","version":"100.0.0-testnet-one.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-one.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"952692e96a75a4d0ad67ece1b1dc7ebb4ffc9617","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-one.4.tgz","fileCount":269,"integrity":"sha512-B6zRlcZAKAxIjniWMfBFRQoWRkJVOlVSZlvH2To5rDPHBl2Nf1FvXbtbNcKyhUOCWWH7lUAHVe2e3CuTC95myQ==","signatures":[{"sig":"MEQCIAEOWBSw006skE6byDHalD/cUUWzMd8ybnXtvdOdp2ZyAiAfBKq1cJyUJUxH8Af/B/S3igLorpMYrfEiIrDpPoqTuQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37027516},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"96b775f9ed19171a2834cb1e64c7c81d3a4d3b29","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-one.4","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-one.4","@streamr/config":"^5.0.1","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-one.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-one.4","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.3","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.201","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-one.4","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-one.4_1702297338659_0.2694312989022969","host":"s3://npm-registry-packages"}},"100.0.0-testnet-two.0":{"name":"streamr-client","version":"100.0.0-testnet-two.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-two.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"968ff45f38b0530485c20adc5cc0021ad790f31a","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-two.0.tgz","fileCount":269,"integrity":"sha512-GjAl8S9ywKwN/Te8pS4ijntIzbRJTtt4AmKqDskCQeX1N9d4T4IoGys0Ey7/G7wxBVQ+wCggA7eVE+e0VHeQog==","signatures":[{"sig":"MEUCIEoIC7o4sjETvuLFyovwXBlRO3udkgqfeW47NSDeQbF/AiEAy6E63wKg46SRaYlWzjmQnlyEpvFlHSPCUHZhQazXeD8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31489266},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"a33f89cb3a3936fb8cc591de1854fe1716aa52c7","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-two.0","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-two.0","@streamr/config":"^5.1.0","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-two.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-two.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.4","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-two.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-two.0_1702674985202_0.7661981069218968","host":"s3://npm-registry-packages"}},"100.0.0-testnet-two.1":{"name":"streamr-client","version":"100.0.0-testnet-two.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-two.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"5b2fb8c4f5c8742d2677938615da5d24a4be73cb","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-two.1.tgz","fileCount":269,"integrity":"sha512-weICdhmu8qUPPeX7QmZdsF3bwjC5xFrF35WoWly0bOnVT+G+G4krHf/wxgbtqKMzToXsAAzd482rkdu1aiemgw==","signatures":[{"sig":"MEYCIQDOs/ys9+HPCwN8uT6heOr9a9UkSPgBWt59jRltcMvOSgIhAMj91hLAEVqQiXn2wXRZJ2IpZnVZyuwo7BQ2E6xeTogf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31508375},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"d46a973078e4e5b638766c5ece8029fcd8887271","_npmUser":{"name":"teogeb","email":"teo@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"9.8.1","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.18.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-two.1","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-two.1","@streamr/config":"^5.1.0","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-two.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-two.1","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.4","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-two.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-two.1_1702916752492_0.6193056555713099","host":"s3://npm-registry-packages"}},"100.0.0-testnet-two.2":{"name":"streamr-client","version":"100.0.0-testnet-two.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-two.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"028ae636387bf5baf19c4f9822b882531d10b0d1","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-two.2.tgz","fileCount":269,"integrity":"sha512-RHSALMWu2LhhoQ/o8H/oBycx5I1UaCUoQo4haSqWyGiQaLMOBo5RNOKeArFa/dRmrv+XlrdB+LAogdTOlFm3Nw==","signatures":[{"sig":"MEYCIQDnwm5kc8Z31XC53PYWGctTfezGCZdDX46aC7XXtjy7awIhALOqN/zyyiqVPNG3MmFYskXrUqXSW1MVy9/m7MeDpFaG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31505782},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"191a34522ad8a32c386e2ab981748e390fb1fac1","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.19.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-two.2","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-two.2","@streamr/config":"^5.1.0","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-two.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-two.2","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.4","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-two.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-two.2_1703087157399_0.11310254495262462","host":"s3://npm-registry-packages"}},"100.0.0-testnet-two.3":{"name":"streamr-client","version":"100.0.0-testnet-two.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-two.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"de3a1c373e746857daffd7358a6b30fcea6825fa","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-two.3.tgz","fileCount":269,"integrity":"sha512-TAIoIHOihZx3ZVxCUR8CwLUNKd3Qmf2/lVK0RQ9SuTLAbsHDwqtACBo9ykSXMmdqsjAHI1rYyx7tyKcJm8nOhg==","signatures":[{"sig":"MEQCIGEYqjzXyRte8km8nz1sz+EEEQsDzy4dvaGk9/9Wf7iEAiBKFb3ETspxA541O4sOTIcsxch2wJgstNHUjNSqD2M3ng==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31492183},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"230d3703517806aafd014c359c31b31a85a3be6d","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.19.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-two.3","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-two.3","@streamr/config":"^5.1.0","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-two.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-two.3","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.4","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-two.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-two.3_1703175121370_0.3309480266578908","host":"s3://npm-registry-packages"}},"100.0.0-testnet-two.4":{"name":"streamr-client","version":"100.0.0-testnet-two.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-two.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"8ea3faa83e833dc763e5846e3c8efeba8c8dfe24","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-two.4.tgz","fileCount":269,"integrity":"sha512-K4Io5KIQtqQZ9+YxpiSQXaN1cpzzOTmTTMm1gPdQGRL+JB43TjoGSQS8TPCmOSpfer7hcKr1GPqE3hx8eRbZKg==","signatures":[{"sig":"MEYCIQDEBPjidpzXeQiwwNcNa2WvjINI3gon29NFv5FVtfHdYAIhAOCPFaBu58cmM+w5QmrgTjgqvFAtNpmlXctGkPuiLTfA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31491358},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"1f6fec0d6ede5ca47b63ca898a4782368656efa9","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"18.19.0","dependencies":{"idb":"^7.1.1","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","split2":"^4.2.0","sqlite":"^5.1.1","core-js":"^3.33.3","p-limit":"^3.1.0","sqlite3":"^5.0.3","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-two.4","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.4","@streamr/utils":"100.0.0-testnet-two.4","@streamr/config":"^5.1.0","readable-stream":"^4.4.2","reflect-metadata":"^0.1.13","@streamr/protocol":"100.0.0-testnet-two.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.4","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.61","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-two.4","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.4","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.2","@babel/core":"^7.23.3","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","@types/split2":"^4.2.3","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.3","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-two.4","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.0","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.2.5","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.4","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.3","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-two.4_1703263971349_0.13313374086479546","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.0":{"name":"streamr-client","version":"100.0.0-testnet-three.0","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.0","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"d1c417f995c93c1ffb5b977631029e20571facca","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.0.tgz","fileCount":263,"integrity":"sha512-0VH1lYye4wqlgSmKqmBHHvm3WAlTHS7CrntlewLi3ezr/hx7XpprDIZRVvalxE1UwvMsXXr8fNgsu0n5qfMJDg==","signatures":[{"sig":"MEQCIGk6jUWEsXVOzHvIm6VkApYE088oHrwLazSpxopF+tDQAiAXHJkeZcek0fcl2prmga1WNSL5W/uep7jNNGeZRwaTuA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31537760},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"4eab7c508eb5870ef3ca8b4b0141a89fe0da1569","_npmUser":{"name":"harbu","email":"harbuzen@gmail.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.3.0","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.0","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.0","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.8","@streamr/utils":"100.0.0-testnet-three.0","@streamr/config":"^5.1.0","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.0","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.8","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.0","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.7","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.8","@babel/core":"^7.23.7","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.8","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.0","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.7","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.7","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.0_1705593184605_0.14712495916228674","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.1":{"name":"streamr-client","version":"100.0.0-testnet-three.1","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.1","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"3338d20d4ae8e51b0c0179738b3db7f86b8ba683","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.1.tgz","fileCount":263,"integrity":"sha512-XUFcxxz81sLmEhafDTSPuz1Mg4lrKLhZMYshBRGDeTyPj37XC79BiCBRC5tk2eDYZOlfVzSsYwcg/FK6wi0Kuw==","signatures":[{"sig":"MEUCIQCjB6BYwuX49IxDHrpUrOlLD1b3mCfxwCD6xw/6/4RchgIgF8GYCEPTNkwPkcF1cqfktkBKITRpmdYiIS6HaK1auHA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31558362},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"12c8160f12b99c6cb66f84043d45148c0316f0e4","_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.0","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.1","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.8","@streamr/utils":"100.0.0-testnet-three.1","@streamr/config":"^5.1.0","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.1","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.8","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.1","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.7","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.8","@babel/core":"^7.23.7","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.8","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.1","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.7","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.7","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.1_1705933787112_0.6540073436290978","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.2":{"name":"streamr-client","version":"100.0.0-testnet-three.2","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.2","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"35db04ca6337f130ba181bbb77b82d5480a03813","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.2.tgz","fileCount":263,"integrity":"sha512-ACuLbnh2QR5aAKzU6nZCbd79FnkSQJSEpdjX4TnxVA1f5cfKGfrX3CC/7ujn+HWUok657sYDRobD/QGTh50kwQ==","signatures":[{"sig":"MEUCIQDomgLaCot2cL27pQOX0JBXv34jXnz0edok2FE8Vfh/CAIgV4+O9cN9ongN6ze27NF0Zu8bh7tpfCd8bcwaoLsr3mo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31565694},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"954f4d4132e500e7eb900119744fe19babbe0a3c","_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.0","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.2","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.8","@streamr/utils":"100.0.0-testnet-three.2","@streamr/config":"^5.1.2","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.2","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.8","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.2","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.7","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.8","@babel/core":"^7.23.7","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^119.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.8","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.2","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.7","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.7","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.2_1706104947705_0.4779709987691452","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.3":{"name":"streamr-client","version":"100.0.0-testnet-three.3","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.3","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"288bfe34a885648a323a6c95db1302d393db4353","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.3.tgz","fileCount":263,"integrity":"sha512-NYSB946aitO6DOHczsgq61V/FWEKjVbIzHzxoq+bZXPrCg7NNHEENtMQB/++dskjbsdNpah3rQVKH30gBMKEJQ==","signatures":[{"sig":"MEUCIFWso9zRXmXhl5gZADARD6OOwT9CHKkGjzcdNEWCQ8CpAiEA5F3xt9y//1Yjm8mTLFVBq5WLL55D8SZqA2WkjJ5mBzw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31561779},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"742ac8c9d1c43a6e1fb09988a39d9c5085de60b2","_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.0","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","secp256k1":"^5.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.3","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.8","@streamr/utils":"100.0.0-testnet-three.3","@streamr/config":"^5.1.2","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.3","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.8","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.3","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.7","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.8","@babel/core":"^7.23.7","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^120.0.0","concurrently":"^8.2.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@types/secp256k1":"^4.0.6","@babel/preset-env":"^7.23.8","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.3","babel-plugin-lodash":"^3.3.4","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.7","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.7","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.3_1706802969876_0.8296671391334056","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.4":{"name":"streamr-client","version":"100.0.0-testnet-three.4","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.4","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"49aa24b8d67d7ee80cafe20e1067b5e85bc03421","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.4.tgz","fileCount":261,"integrity":"sha512-TbIhwX3vvlFBAy5qLI7WRJTksZY6f22DoO6NDyGlg147YHfjyWK0ly2MxDonqlNl5zzJ5ql0oOBypMcNvZIe4Q==","signatures":[{"sig":"MEUCIQD+CK5GfV4ehyA2hrfR+P5I4cMql6HAXxcNvLf2osdLIQIgYovOfPR5oEkVG6TJMQx4sv7HtxEQtP16zqKGuxqq//U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16229185},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"d9560ed1f60ba7dafb987df025fd77baf488316c","_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.0","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.4","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.8","@streamr/utils":"100.0.0-testnet-three.4","@streamr/config":"^5.1.2","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.4","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.8","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.4","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.7","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.8","@babel/core":"^7.23.7","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^120.0.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@babel/preset-env":"^7.23.8","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.4","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.7","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.7","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.4_1707758443559_0.29227906256078673","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.5":{"name":"streamr-client","version":"100.0.0-testnet-three.5","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.5","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"7d94e352728a194bfab8cd26d0e092122f1a066c","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.5.tgz","fileCount":263,"integrity":"sha512-kODJelTlxklB2p8w7ppmzjRm78WnYGOvg6CRGfgPUim4cHZYDeSyk+BF5yuzA9bqDePDonHuPrf/nMuWjv3yKg==","signatures":[{"sig":"MEUCIQDe4EO4QlWNi6t/BCPqtQ1ntjAdFQKDoYllRU9mFs1m6wIgHD0olBcBkJAd3MHaouB7UUlcrC7ZAKT5PzR65y6bXig=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34706478},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"6d2b2fa45ef962197490498a08c315d6bea5b215","_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.0","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.5","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.8","@streamr/utils":"100.0.0-testnet-three.5","@streamr/config":"^5.1.2","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.5","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.8","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.5","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.7","webpack":"^5.89.0","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.3.8","@babel/core":"^7.23.7","@types/heap":"^0.2.34","@types/uuid":"^9.0.7","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^120.0.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@babel/preset-env":"^7.23.8","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.5","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.7","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.7","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.5_1707828378367_0.1258048076142666","host":"s3://npm-registry-packages"}},"100.0.0-testnet-three.6":{"name":"streamr-client","version":"100.0.0-testnet-three.6","author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","_id":"streamr-client@100.0.0-testnet-three.6","maintainers":[{"name":"samigabor","email":"samoila.gabor@yahoo.com"},{"name":"fonty1","email":"mr.matto@gmail.com"},{"name":"hpihkala","email":"henri.pihkala@streamr.com"},{"name":"tumppi","email":"tuomas.koponen@streamr.com"},{"name":"harbu","email":"harbuzen@gmail.com"},{"name":"mariusz_io","email":"mariusz@mariusz.io"},{"name":"pzsavola","email":"petri.savolainen@spaceify.net"},{"name":"juslesan","email":"santeri.juslenius@gmail.com"},{"name":"jtakalai","email":"juuso.takalainen@streamr.com"},{"name":"streamr-dev","email":"devtools@streamr.com"},{"name":"teogeb","email":"teo@streamr.com"},{"name":"samt1803","email":"samt1803@gmail.com"}],"homepage":"https://github.com/streamr-dev/network#readme","bugs":{"url":"https://github.com/streamr-dev/network/issues"},"dist":{"shasum":"f1cabc0d9657b62723656209b91353db03018871","tarball":"https://registry.npmjs.org/streamr-client/-/streamr-client-100.0.0-testnet-three.6.tgz","fileCount":263,"integrity":"sha512-uih3/XgjZUlgMYzDtDYh76PSWLEHiqu8dvA/oREI5m82UOAJtUj4Ai7v71ZzYy8kynv2v5JKZvVlKG9VoQ7j/Q==","signatures":[{"sig":"MEYCIQDwbp81plV1kZMIGQnbVufvdwD02/Rr9FvJ4MRt5Q/EfgIhAPbdYmgxRCxTAVEokOwsXtZgxiSXLz70HBYf8UurQBnd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34931079},"main":"./src/exports-commonjs.js","types":"./types/src/index.d.ts","readme":"<p align=\"center\">\n  <a href=\"https://streamr.network\">\n    <img alt=\"Streamr\" src=\"https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png\" width=\"600\" />\n  </a>\n</p>\n\n<h1 align=\"left\">\n  Streamr JavaScript Client\n</h1>\n\n![latest npm package version](https://img.shields.io/npm/v/streamr-client?label=latest)\n![GitHub stars](https://img.shields.io/github/stars/streamr-dev/network-monorepo?style=social)\n[![Discord Chat](https://img.shields.io/discord/801574432350928907.svg?label=Discord&logo=Discord&colorB=7289da)](https://discord.gg/FVtAph9cvz)\n\nThe Streamr Client library allows you to easily interact with the [Streamr Network](https://streamr.network) from\nJavaScript-based environments, such as browsers and [Node.js](https://nodejs.org). The library wraps a Streamr light node for publishing and subscribing to messages. It also contains convenience functions for creating and managing streams.\n\n**[Checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n\n## Quickstart\nThe client is available on [NPM](https://www.npmjs.com/package/streamr-client) and can be installed simply by:\n\n```\nnpm install streamr-client\n```\n\nIf using TypeScript you can import the library with:\n```js\nimport { StreamrClient } from 'streamr-client'\n```\nIf using Node.js you can import the library with:\n\n```js\nconst { StreamrClient } = require('streamr-client')\n```\n\n## Environments and frameworks\n**NodeJS**\n- NodeJS `16.13.x` is the minimum required version. NodeJS `18.13.x`, NPM `8.x` and later versions are recommended.\n\n**Browser (Website/WebApps)**\n- To use with react please see [streamr-client-react](https://github.com/streamr-dev/streamr-client-react)\n- For usage in the browser include the latest build, e.g. by including a `<script>` tag pointing at a CDN:\n- `<script src=\"https://unpkg.com/streamr-client@latest/streamr-client.web.min.js\"></script>`\n\n**Browser extension**\n- Due to the stricter security rules inside browser extensions you must use the web build version of the Streamr Client.\n\n## Usage\n\n### Full API reference\nFor a full API reference visit https://api-docs.streamr.network/.\n\n### Client creation\nIn Streamr, Ethereum accounts are used for identity. You can generate an Ethereum private key using any Ethereum wallet, or you can use the utility function [`StreamrClient.generateEthereumAccount()`](#utility-functions), which returns the address and private key of a fresh Ethereum account. A private key is not required if you are only subscribing to public streams on the Network.\n\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        privateKey: 'your-private-key'\n    }\n})\n```\n\nAuthenticating with an Ethereum private key contained in an Ethereum (web3) provider (e.g. MetaMask):\n```js\nconst streamr = new StreamrClient({\n    auth: {\n        ethereum: window.ethereum,\n    }\n})\n```\n\nYou can also create an anonymous client instance that can interact with public streams:\n```js\nconst streamr = new StreamrClient()\n```\n\n### Creating a stream\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nconsole.log(stream.id) // e.g. `0x12345.../foo/bar`\n```\n\n### Subscribing\n```js\nconst streamId = '0x7d275b79eaed6b00eb1fe7e1174c1c6f2e711283/ethereum/gas-price'\n\nstreamr.subscribe(streamId, (message) => {\n    // handle for individual messages\n})\n\n```\n### Publishing\nPublishing messages requires your Ethereum account to have permission to publish. See the [stream permission docs](https://docs.streamr.network/usage/streams/permissions) for more information.\n\n```js\n// Requires MATIC tokens (Polygon blockchain gas token)\nconst stream = await streamr.createStream({\n    id: '/foo/bar'\n})\n\nawait stream.publish({ timestamp: Date.now() })\n```\n\n### Requesting historical messages\nBy default `subscribe` will not request historical messages.\n\nYou can fetch historical messages with the `resend` method:\n```js\nstreamr.resend(streamId, { last: 10 }, (msgs) => {\n  console.log(\"messages\": msgs);\n});\n```\n\n___\n\n**This Readme only scratches the surface of what's possible - be sure to [checkout our documentation](https://docs.streamr.network) for the full usage instructions.**\n","browser":"./streamr-client.web.js","exports":{"browser":"./streamr-client.web.js","default":{"types":"./dist/types/src/index.d.ts","import":"./src/exports-esm.mjs","require":"./src/exports-commonjs.js"}},"gitHead":"1bca27ae9446bd30324eb5d319cf36d73012310b","_npmUser":{"name":"streamr-dev","email":"devtools@streamr.com"},"#IMPORTANT":"babel-runtime must be in dependencies, not devDependencies","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"_npmVersion":"10.2.3","description":"JavaScript client library for Streamr","directories":{},"_nodeVersion":"20.10.0","dependencies":{"idb":"^8.0.0","sha3":"^2.1.4","uuid":"^9.0.1","lodash":"^4.17.21","sqlite":"^5.1.1","core-js":"^3.35.1","p-limit":"^3.1.0","sqlite3":"^5.1.7","lit-siwe":"^1.1.8","tsyringe":"^4.8.0","env-paths":"^2.2.1","p-memoize":"4.0.4","quick-lru":"^7.0.0","node-fetch":"^2.7.0","p-throttle":"4.1.1","ts-toolbelt":"^9.6.0","@streamr/dht":"100.0.0-testnet-three.6","eventemitter3":"^5.0.0","ts-essentials":"^9.4.1","@babel/runtime":"^7.23.9","@streamr/utils":"100.0.0-testnet-three.6","@streamr/config":"^5.1.2","readable-stream":"^4.5.2","reflect-metadata":"^0.2.1","@streamr/protocol":"100.0.0-testnet-three.6","@ethersproject/abi":"^5.5.0","@ethersproject/web":"^5.5.0","@lit-protocol/core":"^2.2.5","@ethersproject/bytes":"^5.5.0","@ethersproject/wallet":"^5.5.0","@babel/runtime-corejs3":"^7.23.9","@ethersproject/address":"^5.5.0","@ethersproject/bignumber":"^5.5.0","@ethersproject/constants":"^5.5.0","@ethersproject/contracts":"^5.5.0","@ethersproject/providers":"^5.5.0","@lit-protocol/uint8arrays":"^2.2.63","@ethersproject/transactions":"^5.5.0","@streamr/trackerless-network":"100.0.0-testnet-three.6","@ethersproject/abstract-signer":"^5.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ajv":"^8.8.2","util":"^0.12.4","bytes":"^3.1.1","buffer":"^6.0.3","express":"^4.17.1","typedoc":"^0.25.8","webpack":"^5.90.1","benchmark":"^2.1.4","ts-loader":"^9.5.1","weak-napi":"^2.0.2","nightwatch":"^3.4.0","@babel/core":"^7.23.9","@types/heap":"^0.2.34","@types/uuid":"^9.0.8","ajv-formats":"^2.1.1","webpack-cli":"^5.1.4","babel-loader":"^9.1.3","chromedriver":"^120.0.2","@jest/globals":"^29.5.0","@types/lodash":"^4.14.202","webpack-merge":"^5.10.0","@babel/preset-env":"^7.23.9","@types/node-fetch":"^2.6.4","crypto-browserify":"^3.12.0","jest-leak-detector":"^27.3.1","jest-matcher-utils":"^29.5.0","@streamr/test-utils":"100.0.0-testnet-three.6","eslint-plugin-import":"^2.29.1","lodash-webpack-plugin":"^0.11.6","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.1","@babel/preset-typescript":"^7.23.3","@ethersproject/wordlists":"^5.5.0","git-revision-webpack-plugin":"^5.0.0","node-polyfill-webpack-plugin":"^2.0.1","@babel/plugin-transform-runtime":"^7.23.9","babel-plugin-add-module-exports":"^1.0.4","@babel/plugin-proposal-decorators":"^7.23.9","@babel/plugin-transform-modules-commonjs":"^7.23.3","babel-plugin-transform-typescript-metadata":"^0.3.2"},"optionalDependencies":{"bufferutil":"^4.0.8","utf-8-validate":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client_100.0.0-testnet-three.6_1708008560632_0.9010076667318752","host":"s3://npm-registry-packages"}}},"time":{"created":"2015-12-30T14:35:20.700Z","modified":"2026-05-28T14:47:35.519Z","0.8.0":"2015-12-30T14:35:20.700Z","0.8.1":"2016-04-21T09:36:31.307Z","0.9.0":"2017-04-10T08:55:59.912Z","0.9.1":"2017-04-10T15:20:28.302Z","0.9.2":"2017-07-15T15:06:22.213Z","0.9.3":"2017-07-16T10:22:46.418Z","0.10.0":"2018-04-12T12:31:55.285Z","0.10.1":"2018-04-18T14:01:45.235Z","0.10.2":"2018-05-01T13:06:20.911Z","0.10.3":"2018-05-22T07:56:03.740Z","0.11.0-beta.1":"2018-06-04T08:51:28.016Z","0.11.0":"2018-06-11T14:07:01.293Z","0.11.1":"2018-08-06T15:39:46.841Z","0.11.2":"2018-08-09T19:52:48.701Z","0.12.0":"2018-08-23T15:19:41.230Z","0.12.1":"2018-09-02T20:45:54.591Z","0.12.2":"2018-10-01T13:26:51.154Z","1.0.0":"2018-12-05T21:46:30.097Z","2.0.0-beta.1":"2019-03-25T10:04:40.750Z","1.0.1":"2019-03-25T11:07:23.227Z","2.0.0-beta.2":"2019-03-27T09:54:12.581Z","1.0.2":"2019-03-28T18:20:13.664Z","2.0.0-beta.3":"2019-03-29T10:45:00.474Z","2.0.0-beta.4":"2019-03-29T10:51:10.297Z","2.0.0-beta.5":"2019-04-11T09:43:17.707Z","2.0.0-beta.6":"2019-05-10T07:58:58.880Z","2.0.0-beta.7":"2019-05-10T10:57:13.250Z","2.0.0-beta.8":"2019-05-13T12:36:16.964Z","2.0.0-beta.9":"2019-05-13T14:12:17.609Z","2.0.0":"2019-05-17T11:10:57.558Z","2.0.1":"2019-05-24T08:20:29.952Z","2.0.2":"2019-05-24T17:01:39.414Z","2.0.3":"2019-06-19T15:41:14.714Z","2.1.0-beta.0":"2019-06-28T07:20:34.255Z","2.1.0":"2019-07-03T08:57:01.991Z","2.1.1":"2019-07-05T06:12:45.166Z","2.2.0-beta.0":"2019-08-16T13:19:32.527Z","2.2.0":"2019-08-28T11:19:50.468Z","2.2.1":"2019-09-04T15:56:09.371Z","2.2.2":"2019-09-26T08:29:38.935Z","2.2.3":"2019-10-21T11:15:26.889Z","2.2.4":"2019-10-23T12:45:21.362Z","2.2.5":"2019-10-23T17:41:19.103Z","2.2.6":"2019-11-11T08:49:23.929Z","2.2.7":"2019-11-14T08:01:23.689Z","3.0.0-beta.0":"2019-11-29T08:17:34.472Z","3.0.0":"2019-12-10T14:04:05.284Z","3.0.1":"2020-01-13T08:31:35.477Z","3.1.0":"2020-02-04T21:47:30.237Z","3.1.1":"2020-02-05T15:25:12.257Z","3.1.2":"2020-02-06T13:06:16.847Z","3.1.3":"2020-02-26T14:21:12.262Z","3.2.0":"2020-03-18T14:14:42.776Z","3.2.1-beta.0":"2020-04-16T17:48:10.720Z","3.2.1-beta.1":"2020-04-20T09:43:53.082Z","3.2.1":"2020-04-20T15:25:33.322Z","4.0.0-beta.0":"2020-04-20T16:05:48.270Z","4.0.0-beta.1":"2020-05-04T15:47:51.249Z","4.0.0-beta.2":"2020-05-25T17:27:48.630Z","4.1.0-beta.0":"2020-05-29T07:55:24.265Z","4.1.0-beta.1":"2020-07-21T09:58:42.339Z","4.1.0-beta.2":"2020-08-04T18:14:29.139Z","4.2.0-alpha.0":"2020-08-20T06:42:23.813Z","4.1.0":"2020-09-02T20:27:27.780Z","4.1.1":"2020-09-08T19:01:47.671Z","4.2.0-alpha.1":"2020-09-28T07:10:29.403Z","4.2.0-alpha.2":"2020-09-28T08:36:55.112Z","4.2.0-alpha.3":"2020-10-06T09:31:26.641Z","4.2.0-alpha.4":"2020-10-08T11:25:05.767Z","4.1.2":"2020-10-16T13:53:44.460Z","4.2.0-alpha.5":"2020-10-19T09:03:46.468Z","4.2.0-alpha.6":"2020-10-26T12:45:23.502Z","4.1.3":"2020-10-28T15:51:25.306Z","4.2.0-alpha.7":"2020-11-03T11:35:00.692Z","4.2.0-alpha.8":"2020-11-04T12:04:44.019Z","4.2.0-alpha.9":"2020-11-12T11:50:05.897Z","4.2.0-alpha.10":"2020-11-13T12:27:41.147Z","4.2.0-alpha.11":"2020-11-18T13:27:21.547Z","5.0.0-alpha.1":"2020-11-20T22:11:43.270Z","5.0.0-alpha.2":"2020-11-20T22:25:56.486Z","5.0.0-alpha.3":"2020-11-24T18:20:46.894Z","4.2.0-alpha.12":"2020-11-27T07:27:44.824Z","5.0.0-alpha.4":"2020-12-01T15:38:46.602Z","4.1.4":"2020-12-08T15:41:29.505Z","4.2.0-alpha.13":"2020-12-18T14:08:20.579Z","5.0.0-beta.1":"2020-12-18T19:02:15.087Z","4.2.0-alpha.14":"2021-01-14T18:06:31.158Z","5.0.0-beta.2":"2021-01-15T19:04:37.427Z","4.1.5":"2021-01-19T02:42:32.574Z","4.1.6":"2021-01-20T22:11:45.253Z","5.0.0-beta.3":"2021-01-20T22:16:44.938Z","5.0.0-beta.4":"2021-01-22T17:13:49.005Z","5.0.0-beta.5":"2021-01-27T02:41:29.859Z","5.0.0-beta.6":"2021-02-10T18:31:13.938Z","5.0.0-beta.7":"2021-02-23T21:09:58.283Z","5.0.0-alpha.5":"2021-03-11T08:53:06.567Z","5.0.0-alpha.6":"2021-03-11T10:13:56.821Z","5.0.0-alpha.7":"2021-03-11T10:14:53.872Z","5.0.0-beta.8":"2021-03-11T15:20:49.998Z","5.0.0-beta.9":"2021-03-11T15:25:53.221Z","5.0.0-beta.10":"2021-03-12T10:08:54.134Z","5.0.0":"2021-03-12T17:59:59.326Z","5.0.1":"2021-03-12T19:20:01.019Z","5.1.0":"2021-03-15T20:12:36.785Z","5.2.0-beta":"2021-03-25T22:57:45.658Z","5.2.1":"2021-03-29T19:15:35.857Z","5.3.0-alpha.1":"2021-03-30T10:43:19.434Z","5.3.0-alpha.2":"2021-03-31T12:44:52.238Z","5.3.0-beta.0":"2021-04-14T15:10:06.617Z","5.3.0-alpha.3":"2021-05-05T10:05:24.888Z","5.4.0":"2021-05-21T01:37:56.852Z","5.4.1":"2021-05-21T14:16:45.227Z","5.4.1-alpha.1":"2021-05-26T13:34:06.216Z","5.4.1-alpha.2":"2021-05-26T13:56:33.028Z","5.4.2":"2021-06-04T18:24:42.680Z","5.4.3":"2021-06-17T14:38:29.948Z","5.4.4":"2021-06-17T21:51:04.003Z","6.0.0-alpha.0":"2021-09-07T20:41:34.108Z","6.0.0-alpha.1":"2021-09-07T20:56:19.557Z","6.0.0-alpha.2":"2021-09-08T11:20:07.964Z","6.0.0-alpha.3":"2021-09-09T13:05:13.165Z","6.0.0-alpha.4":"2021-09-10T20:56:19.391Z","6.0.0-alpha.5":"2021-09-15T23:21:13.376Z","6.0.0-alpha.6":"2021-09-16T01:20:41.440Z","5.4.5":"2021-09-22T13:36:59.837Z","6.0.0-alpha.7":"2021-10-05T20:12:39.487Z","6.0.0-alpha.8":"2021-10-06T10:29:43.118Z","6.0.0-alpha.9":"2021-10-07T13:25:50.288Z","6.0.0-alpha.10":"2021-10-07T15:36:36.489Z","6.0.0-alpha.11":"2021-10-11T12:40:00.086Z","6.0.0-alpha.12":"2021-10-18T15:58:04.880Z","6.0.0-alpha.13":"2021-10-19T01:30:59.370Z","6.0.0-alpha.14":"2021-10-19T17:35:27.870Z","6.0.0-alpha.15":"2021-10-19T18:12:48.209Z","6.0.0-alpha.16":"2021-10-19T18:25:48.068Z","6.0.0-alpha.17":"2021-10-19T19:00:45.356Z","6.1.0-decentralised-registries-experimental.0":"2021-11-04T10:55:30.997Z","6.1.0-decentralised-registries-experimental.1":"2021-11-16T10:26:18.724Z","6.1.0-decentralised-registries-experimental.2":"2021-11-17T07:41:49.952Z","6.1.0-decentralised-registries-experimental.3":"2021-11-17T12:02:53.546Z","5.5.0":"2021-11-17T13:10:55.638Z","6.1.0-ocr-experimental.4":"2021-11-19T12:38:06.119Z","6.1.0-ocr-experimental.5":"2021-11-22T08:28:15.939Z","6.1.0-ocr-experimental.7":"2021-11-22T09:00:13.650Z","5.5.1":"2021-11-23T13:33:51.850Z","5.5.2":"2021-11-23T22:04:51.890Z","5.5.3":"2021-11-25T13:48:43.528Z","5.5.4":"2021-11-25T16:03:27.926Z","5.5.5":"2021-11-26T19:47:38.176Z","6.1.0-ocr-experimental.8":"2021-11-29T09:43:01.333Z","5.5.6":"2021-11-29T13:44:25.594Z","6.1.0-ocr-experimental.9":"2021-11-30T08:40:59.169Z","5.5.7":"2021-11-30T11:35:05.277Z","6.1.0-ocr-experimental.10":"2021-12-01T10:18:20.674Z","6.0.0-alpha.18":"2021-12-10T11:06:07.730Z","6.0.0-alpha.19":"2021-12-10T11:26:58.914Z","6.1.0-ocr-experimental.12":"2021-12-14T12:08:05.505Z","6.1.0-ocr-experimental.13":"2021-12-20T15:51:06.894Z","6.1.0-ocr-experimental.14":"2021-12-27T14:39:37.099Z","6.1.0-ocr-experimental.15":"2021-12-27T14:46:41.925Z","6.1.0-ocr-experimental.20":"2022-01-17T12:13:19.485Z","5.5.8":"2022-01-17T20:16:46.529Z","6.0.0-alpha.21":"2022-01-19T11:46:05.595Z","6.0.0-alpha.22":"2022-01-24T15:20:35.341Z","6.0.0-alpha.23":"2022-01-26T09:57:21.205Z","6.0.0-alpha.24":"2022-01-26T12:35:22.527Z","6.0.0-alpha.25":"2022-01-26T18:29:38.224Z","6.0.0-alpha.26":"2022-01-27T17:49:13.923Z","6.0.0-alpha.27":"2022-01-31T14:14:48.144Z","6.0.0-alpha.28":"2022-02-01T13:06:35.393Z","6.0.0-alpha.29":"2022-02-02T11:32:28.736Z","6.0.0-alpha.30":"2022-02-03T12:32:56.579Z","6.0.0-alpha.31":"2022-02-04T12:41:58.803Z","6.0.0-alpha.32":"2022-02-07T11:13:06.390Z","6.0.0-alpha.33":"2022-02-07T11:50:53.403Z","6.0.0-beta.1":"2022-02-07T14:11:40.671Z","6.0.0-beta.2":"2022-02-10T13:38:21.474Z","6.0.0-beta.3":"2022-02-17T15:03:07.966Z","6.0.0-beta.4":"2022-02-22T17:01:01.361Z","6.0.0":"2022-02-23T19:00:20.264Z","6.0.1":"2022-02-24T17:52:00.725Z","6.0.2":"2022-03-04T12:44:31.636Z","6.0.3":"2022-04-25T12:56:21.356Z","6.0.4":"2022-04-28T12:25:35.562Z","6.0.5":"2022-05-10T07:25:27.719Z","6.0.6":"2022-05-24T11:57:14.064Z","6.0.7":"2022-05-25T13:21:08.948Z","6.0.8":"2022-05-31T09:12:23.903Z","6.0.9":"2022-06-20T09:17:46.691Z","6.1.0-beta.1":"2022-07-13T10:04:48.707Z","6.1.0-beta.2":"2022-07-29T11:16:10.888Z","6.1.0-beta.3":"2022-09-13T10:47:17.087Z","6.1.0-beta.4":"2022-09-30T11:58:16.278Z","6.0.10":"2022-10-03T11:16:14.337Z","7.0.0-beta.0":"2022-10-13T10:44:49.835Z","7.0.0-beta.1":"2022-11-07T15:27:13.453Z","7.0.0-beta.2":"2022-11-08T13:31:20.437Z","7.0.0-beta.3":"2022-11-09T11:24:11.046Z","7.0.0":"2022-11-15T13:33:02.931Z","7.0.1":"2022-11-18T14:33:02.821Z","7.0.2":"2022-11-22T16:33:04.146Z","7.0.3":"2022-11-23T16:15:50.501Z","7.1.0":"2022-11-25T15:16:14.682Z","7.2.0":"2022-12-14T12:48:25.963Z","7.2.1":"2023-01-12T11:56:39.462Z","7.3.0-beta.0":"2023-01-18T15:43:06.632Z","7.3.0":"2023-01-23T16:36:18.657Z","7.4.0-beta.0":"2023-01-27T11:17:57.182Z","7.4.0-beta.1":"2023-01-30T14:51:54.463Z","5.6.0":"2023-02-13T16:40:45.169Z","8.0.0-beta.0":"2023-02-20T13:13:05.228Z","8.0.0":"2023-02-20T15:46:37.094Z","8.0.1":"2023-02-20T16:40:47.572Z","8.0.2":"2023-02-27T13:41:55.024Z","8.0.3-beta.0":"2023-03-08T11:24:56.437Z","8.0.3":"2023-03-08T11:56:14.822Z","8.0.4":"2023-03-20T15:59:41.537Z","8.1.0-beta.0":"2023-03-21T14:34:49.974Z","8.1.0":"2023-03-23T13:48:00.488Z","8.2.0":"2023-04-11T15:09:41.386Z","8.2.1":"2023-04-13T15:08:07.576Z","8.3.0-beta.0":"2023-04-20T11:06:55.966Z","8.3.0-beta.1":"2023-04-25T13:25:56.209Z","8.3.0":"2023-04-26T09:58:18.554Z","8.3.1":"2023-05-03T12:31:01.127Z","8.4.0":"2023-05-09T11:23:47.419Z","8.5.0":"2023-05-10T09:28:16.644Z","8.5.0-nolit":"2023-05-16T12:50:30.393Z","8.5.0-nolit.1":"2023-05-16T13:03:31.453Z","8.5.1":"2023-05-29T09:23:07.612Z","8.5.2":"2023-05-31T08:52:42.214Z","8.5.3":"2023-06-07T11:20:10.953Z","8.5.4":"2023-06-26T12:30:33.214Z","8.5.5":"2023-07-06T13:17:59.340Z","8.5.5-nolit.1":"2023-07-06T13:34:45.970Z","0.0.1-tatum.0":"2023-08-22T13:33:19.192Z","0.0.1-tatum.1":"2023-09-18T13:25:15.720Z","0.0.1-tatum.2":"2023-09-20T13:10:29.450Z","0.0.1-tatum.3":"2023-09-29T12:53:42.114Z","0.0.1-tatum.4":"2023-10-03T11:16:34.002Z","0.0.1-tatum.5":"2023-10-11T14:32:23.710Z","0.0.1-tatum.6":"2023-10-13T13:55:29.266Z","0.0.1-tatum.7":"2023-10-31T13:04:29.111Z","0.0.1-tatum.8":"2023-11-01T20:25:09.813Z","100.0.0-pretestnet.0":"2023-11-02T13:33:44.967Z","100.0.0-pretestnet.2":"2023-11-09T13:25:30.072Z","100.0.0-pretestnet.3":"2023-11-15T15:51:03.904Z","100.0.0-pretestnet.4":"2023-11-20T17:44:38.065Z","100.0.0-pretestnet.6":"2023-11-22T16:36:47.863Z","100.0.0-testnet-one.0":"2023-11-27T18:07:48.138Z","100.0.0-testnet-one.1":"2023-12-04T12:35:15.159Z","100.0.0-testnet-one.2":"2023-12-05T17:24:35.079Z","100.0.0-testnet-one.3":"2023-12-07T15:57:23.127Z","100.0.0-testnet-one.4":"2023-12-11T12:22:19.071Z","100.0.0-testnet-two.0":"2023-12-15T21:16:25.544Z","100.0.0-testnet-two.1":"2023-12-18T16:25:52.855Z","100.0.0-testnet-two.2":"2023-12-20T15:45:57.738Z","100.0.0-testnet-two.3":"2023-12-21T16:12:01.730Z","100.0.0-testnet-two.4":"2023-12-22T16:52:51.676Z","100.0.0-testnet-three.0":"2024-01-18T15:53:04.922Z","100.0.0-testnet-three.1":"2024-01-22T14:29:47.852Z","100.0.0-testnet-three.2":"2024-01-24T14:02:27.998Z","100.0.0-testnet-three.3":"2024-02-01T15:56:10.226Z","100.0.0-testnet-three.4":"2024-02-12T17:20:43.845Z","100.0.0-testnet-three.5":"2024-02-13T12:46:18.714Z","100.0.0-testnet-three.6":"2024-02-15T14:49:20.968Z"},"bugs":{"url":"https://github.com/streamr-dev/network/issues"},"author":{"name":"Streamr Network AG","email":"contact@streamr.network"},"license":"Apache-2.0","homepage":"https://github.com/streamr-dev/network#readme","repository":{"url":"git+https://github.com/streamr-dev/network.git","type":"git","directory":"packages/client"},"description":"JavaScript client library for Streamr","maintainers":[{"email":"henri.pihkala@streamr.com","name":"hpihkala"},{"email":"petri.savolainen@spaceify.net","name":"pzsavola"},{"email":"devtools@streamr.com","name":"streamr-dev"}],"readme":"","readmeFilename":""}