{"bugs":{"url":"https://github.com/streamr-dev/network-monorepo/issues"},"dist":{"shasum":"87d6f0d6e244b7d045dfb72ac3ff3f45a9c6908f","tarball":"https://registry.npmjs.org/streamr-client-protocol/-/streamr-client-protocol-9.0.0-brubeck.0.tgz","fileCount":291,"integrity":"sha512-J3lm041NPKaJCnCtimiC+pkmahS6k+knJoQcpmSprJ6Ezg8jJbisQX4bK7LHc5v+EDkf6u546MDuuXgV8yESTQ==","signatures":[{"sig":"MEYCIQC1xhPM6CUdv/qa6vGMIpCq3NGNlwMiJvtZC8U5L6wctwIhAOBeT9dVGNBNgNQo2jBBheKTNnxSqa5nQfaC46zXwXhB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":667572,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQn3/CRA9TVsSAnZWagAAbKAP/2Jyjw5z8S+ml9/xMHep\nIqzi3hCYWZgRstdZBBLBY49pPwHYeEBH6DBjxWfEM9n8J6nGBOodG1DVoP5a\nuozCj9P5jbqTfo+AOqW4VzH/1QTbxSve6HZFVVorfKhfrtXQraEmBoKS8WBk\nu/vBsbeVT52FEvJJkgoGzHX/pRQZN6bMabiDLeLZhoS27owS8pjd/NzbfMku\nQOLnL7+TtPwvpuUajt96D7BTKkf3qgBIxEUKUfxDMBcTJdklkE16LzKRNTI1\n8oNjTAkljsnpm+B+hghGsJKXNZhs+HF4ohf3kqY033OYEVrHfWf2OLe63jKp\njDFOYxeXI0nASee/VW9eZXZbkHvVWwFptYVsK6z3Qr2mGAuek1Dm2NHrfF43\n2ktceIl8iNBlCkOSnvNk/eTkxYV3cgQ1i5DDMF4Ku/2NIQMCcCYuLYoC4wgZ\nEc7sEZU+DRNcGfDtsMIMGOF1t1lNFwGdcbs/PYnJZvXS0qkoYDr4Sfu+KQYF\n/yDfknx+5zHfFfZHu/XNRnL89eOEJ8cctlJquaJdtVOsKrcLjWUQXUcIMFQs\nT1W1CERML/F2Gqw8QgfwUtctLDu4dvJRbCcKIzMqsjDck+R7yP3NMNBJSgTU\nbCAGgmvJ6djRDmxXoNuYtcKywlbfp5cHQ2J3qbrEC7Bl4XnN9xSms0wDffSu\nMMwo\r\n=np95\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/src/index.js","name":"streamr-client-protocol","types":"dist/src/index.d.ts","author":{"name":"Streamr"},"readme":"# streamr-client-protocol\n\nES6 JS implementations of [Streamr Protocol](https://github.com/streamr-dev/streamr-specs/blob/master/PROTOCOL.md) messages. This is shared code used by (at least):\n \n - [streamr-client-javascript](https://github.com/streamr-dev/streamr-client-javascript)\n - [streamr-broker](https://github.com/streamr-dev/streamr-broker)\n - [streamr-network](https://github.com/streamr-dev/streamr-network)\n\nPlease see the [API Docs](https://streamr-dev.github.io/streamr-client-protocol/) for more detailed documentation.\n\n The package is available on npm as `streamr-client-protocol`.\n \n ## Table of Contents\n- [Use](#use)\n- [Release](#release)\n\n## Use\n\n#### Creating messages from arguments\n\nEvery message type from both the Control Layer and the Message Layer is defined as a class and has a static `create` method that takes class-specific arguments to build an instance of the latest version of the message type. The arguments for each message type are defined in the [protocol documentation](https://github.com/streamr-dev/streamr-specs/blob/master/PROTOCOL.md) and in the definition of the `create` method.\n\nThis example shows how to create a `StreamMessage` and encapsulate it in a `PublishRequest`.\n\n```javascript\nconst streamMessage = new StreamMessage({\n    messageId: new MessageID(...),\n    content\n})\nconst publishRequest = new PublishRequest({\n    requestId: 'requestId', \n    streamMessage, \n})\n```\n\n#### Serializing messages to strings\n\nEvery message type from both the Control Layer and the Message Layer has a `serialize` method, which takes as argument the version to serialize to. By default, it serializes to the latest version of the message type. The `serialize` methods return a string.\n\n```javascript\nconst streamMessage = new StreamMessage({...})\nstreamMessage.serialize() // to latest version\n// > '[31,[\"streamId\",0,1529549961116,\"publisherId\",\"msgChainId\"],null,27,0,{\"foo\":\"bar\"},0,null]'\nstreamMessage.serialize(30) // to MessageLayer version 30\n// > '[30,[\"streamId\",0,1529549961116,\"publisherId\",\"msgChainId\"],null,27,{\"foo\":\"bar\"},0,null]'\n\nconst subscribeRequest = new SubscribeRequest({\n    streamId: 'streamId', \n    streamPartition: 0, \n    sessionToken: 'sessionToken',\n})\nsubscribeRequest.serialize() // to latest version\n// > '[2,9,\"requestId\",\"streamId\",0,\"sessionToken\"]'\nsubscribeRequest.serialize(1) // to ControlLayer version 1\n// > '[1,9,\"streamId\",0,\"sessionToken\"]'\n```\n\n#### Parsing messages from strings\n\nFor deserialization, use the static `deserialize` method that is present in `ControlMessage` for the ControlLayer and `StreamMessage` for the Message Layer. The `deserialize` method accepts both strings and arrays as input.\n\n```javascript\nconst serializedStreamMessage = '[30,[\"streamId\",0,1529549961116,\"publisherId\",\"msgChainId\"],null,27,{\"foo\":\"bar\"},0,null]'\nconst streamMessage = StreamMessage.deserialize(serializedStreamMessage)\n``` \n\nOn the other hand, the Control Layer has many different message types. So we can only know that the `deserialize` method will return a `ControlMessage`. We can use the `type` field to differentiate.\n\n```javascript\nconst serializedMessage = '[1,9,\"streamId\",0,\"sessionToken\"]'\nconst controlMessage = ControlMessage.deserialize(serializedMessage)\nif (controlMessage.type === ControlMessage.TYPES.UnicastMessage) {\n    //treat it as a UnicastMessage\n} else if (controlMessage.type === ControlMessage.TYPES.SubscribeRequest) {\n    //treat it as a SubscribeRequest\n} else if (...) {\n    \n} else {\n    throw new Error(`Unknown type: ${controlMessage.type}`)\n}\n```\n\n## Release\n\nPublishing to NPM is automated via Github Actions. Follow the steps below to publish stable (`latest`) or `beta`.\n\n### Publishing stable (latest)\n1. `git checkout master && git pull`\n2. 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. \n3. `git push --follow-tags`\n4. Wait for Github Actions to run tests\n5. 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","license":"Apache-2.0","scripts":{"docs":"typedoc --options typedoc.js","test":"jest","build":"tsc -p tsconfig-build.json","clean":"rm -rf ./dist/* || true","watch":"tsc --watch","eslint":"eslint '{src,test}/**/*.ts'","prepare":"npm run build","coverage":"jest --coverage","prebuild":"npm run clean","benchmark":"jest test/benchmarks --detectOpenHandles","test-unit":"jest test/unit --detectOpenHandles","test-integration":"jest test/integration --detectOpenHandles"},"_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"homepage":"https://github.com/streamr-dev/network-monorepo#readme","deprecated":"This build is misconfigured.","repository":{"url":"git+https://github.com/streamr-dev/network-monorepo.git","type":"git","directory":"packages/protocol"},"_npmVersion":"6.14.14","description":"JavaScript classes implementing the Streamr client-to-node protocol","directories":{},"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"}],"_nodeVersion":"14.17.5","dependencies":{"heap":"^0.2.6","sha3":"^2.1.4","bip39":"^3.0.4","debug":"^4.3.2","ethers":"^5.3.1","events":"^3.3.0","secp256k1":"^4.0.2","@types/debug":"^4.1.5","promise-memoize":"^1.2.1","@babel/runtime-corejs3":"^7.14.7","strict-event-emitter-types":"^2.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.5","sinon":"^11.1.1","eslint":"^7.29.0","ts-jest":"^27.0.5","typedoc":"^0.21.0","typescript":"^4.3.4","@types/heap":"^0.2.28","@types/jest":"^27.0.1","@types/sinon":"^10.0.2","array-shuffle":"^2.0.0","web3-eth-accounts":"^1.3.6","streamr-test-utils":"^2.0.0","@streamr/dev-config":"^1.0.0","eslint-plugin-promise":"^5.1.0","@types/promise-memoize":"^1.2.0","eslint-config-streamr-ts":"^3.0.1","@typescript-eslint/parser":"^4.28.0","@typescript-eslint/eslint-plugin":"^4.28.0"},"_npmOperationalInternal":{"tmp":"tmp/streamr-client-protocol_9.0.0-brubeck.0_1631747583599_0.5746278326219516","host":"s3://npm-registry-packages"},"_id":"streamr-client-protocol@9.0.0-brubeck.0","version":"9.0.0-brubeck.0"}