{"name":"protons","version":"2.0.2","description":"Protocol Buffers for Node.js without compiliation","leadMaintainer":"Alex Potsides <alex@achingbrain.net>","repository":{"type":"git","url":"git+https://github.com/ipfs/protons.git"},"dependencies":{"protocol-buffers-schema":"^3.3.1","signed-varint":"^2.0.1","uint8arrays":"^2.1.3","varint":"^5.0.0"},"devDependencies":{"aegir":"^25.0.0","benchmark":"^2.1.4","protocol-buffers":"^4.1.0","protons":"^1.0.0","tape":"^4.8.0"},"scripts":{"test":"aegir test","test:browser":"aegir test --target browser","test:node":"aegir test --target node","lint":"aegir lint","release":"aegir release","release-minor":"aegir release --type minor","release-major":"aegir release --type major","build":"aegir build","bench":"node bench"},"bugs":{"url":"https://github.com/ipfs/protons/issues"},"homepage":"https://github.com/ipfs/protons","main":"src/index.js","directories":{"test":"test"},"keywords":["protobuf","protocol","buffers","protocolbuffers","encode","decode","google","serialize","parse","levelup","encodings","encoding"],"author":{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},"license":"MIT","contributors":[{"name":"Mathias Buus","email":"mathiasbuus@gmail.com"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"dignifiedquire","email":"dignifiedquire@gmail.com"},{"name":"Young Hahn","email":"young@mapbox.com"},{"name":"David Dias","email":"daviddias.p@gmail.com"},{"name":"Hector Sanjuan","email":"code@hector.link"},{"name":"Mo Kamioner","email":"mkamioner@gmail.com"},{"name":"tcme","email":"hi@this-connect.me"},{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org"},{"name":"Hugo Dias","email":"hugomrdias@gmail.com"},{"name":"Lars-Magnus Skog","email":"ralphtheninja@riseup.net"},{"name":"Patrick Pfeiffer","email":"patrick@buzzle.at"},{"name":"Kevin Ennis","email":"kennis84@gmail.com"},{"name":"Elijah Insua","email":"tmpvar@gmail.com"},{"name":"Astro","email":"astro@spaceboyz.net"},{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},{"name":"Sergii Shutovskyi","email":"sergii.shutovskyi@trademob.com"},{"name":"Steven Allen","email":"steven@stebalien.com"},{"name":"David Bruant","email":"bruant.d@gmail.com"},{"name":"Irakli Gozalishvili","email":"contact@gozala.io"},{"name":"João Antunes","email":"j.goncalo.antunes@gmail.com"},{"name":"Brendan Ward","email":"bcward@consbio.org"}],"gitHead":"63945dcd67668797a779eb846f275803844c11e2","_id":"protons@2.0.2","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-EIPoT9ftVirJ9QJ3oFoueYUiBhmPqE1AoSBPypLSqbbvHvx+OcUeK9z84YIsk6jda+N3FL58dU1LcWmfGCZGHA==","shasum":"f55ee68f6d183a7efaa80b4bee58e52444f7f1f7","tarball":"http://registry-npm.ywwl.com/protons/download/protons-2.0.2.tgz","fileCount":53,"unpackedSize":67578,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhE/PyCRA9TVsSAnZWagAAh9AP/A4m13xWmdSSsdXQhw02\n6WUhBUpv+EIJRvhaoCy/Ay01l+HJ7jDVSdUy0S/NfrnK5bFi56rp0/kh5Qwt\ntRojnhvneYh1Cksy6IbTIKV+6/hUUXnUM14dg2IX4LGD8FEEQr9+tY/odcqN\nBL5WsslAr+yKBK21IGuX2JSUKEROsQfBtCgiUp7UOE41Cbym2qop8qbHSUjY\nK0oxyEMSmew3Wd8j2GofgdGRIR9amP2lPXd0GQgDUIAOZC0sojVcSOeM4TZ9\nbySbBmqV589SFJaWCXbwvAz6mI04ZQlgsV6BTTwFbFgtpfHRoofG1vS3k14s\n67S7WN7KG9vtsJXRP6c3zrffaNeiQ9c04xOVmYV3/7X7Hy+DzyauhlwiLcp+\n3C3eSHQnYSD6dcY+HYoE+gyffHeLeZWYdffJcJChSbILL43J79PW5w9KLV7O\nx7nQteefu42yBO/CYBZShXNj3clzZSOx+em0wbTWKSMvwBYBuPlD6dO8/KNq\nXxVBsALE7y0igwEHM8GTYw0vUXc5x36gFWTie7nbxHvtomEOQI07dE+LlZvw\nCZALXqhGZ/ocWmSlcENu2NmtypIU7AUZEe63R3IOoutuzz2ENSpRta2C/GiS\n9UdtNEkfU+BzndLVsG+kIMLsw1sDuQtShxeyhMmoSHkTA69ef4hH7As/KxZ7\noz5O\r\n=/+L5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDmmxO8t6H00IOK7C1vm0gBMg6ApwBhTLdRcgnq3XWY5AiBDr/fpN1BT9L4CxUThaSRepsAK4A9pOMR7OLtBrOFrRw=="}],"size":17750,"noattachment":false,"key":"/protons/-/protons-2.0.2.tgz"},"_npmUser":{"name":"achingbrain","email":"alex@achingbrain.net"},"maintainers":[{"name":"jacobheun","email":"jacobheun@gmail.com"},{"name":"daviddias","email":"mail@daviddias.me"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"alanshaw","email":"alan138@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protons_2.0.2_1628697586363_0.6886124694621625"},"_hasShrinkwrap":false,"deprecated":"This module is no longer maintained","readme":"# protons <!-- omit in toc -->\n\n[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)\n[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)\n[![codecov](https://img.shields.io/codecov/c/github/ipfs/protons.svg?style=flat-square)](https://codecov.io/gh/ipfs/protons)\n[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/protons/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> Protobuf to ts transpiler\n\n# About\n\n`protons` is a high performance implementation of [Protocol Buffers v3](https://protobuf.dev/programming-guides/proto3/).\n\nIt transpiles code to TypeScript and supports BigInts for 64 bit types.\n\nThe `protons` module contains the code to compile `.proto` files to `.ts` files and `protons-runtime` contains the code to do serialization/deserialization to `Uint8Array`s during application execution.\n\nPlease ensure you declare them as the correct type of dependencies:\n\n```console\n$ npm install --save-dev protons\n$ npm install --save protons-runtime\n```\n\n## Usage\n\nFirst generate your `.ts` files:\n\n```console\n$ protons ./path/to/foo.proto ./path/to/output.ts\n```\n\nThen run tsc over them as normal:\n\n```console\n$ tsc\n```\n\nIn your code import the generated classes and use them to transform to/from bytes:\n\n```js\nimport { Foo } from './foo.js'\n\nconst foo = {\n  message: 'hello world'\n}\n\nconst encoded = Foo.encode(foo)\nconst decoded = Foo.decode(encoded)\n\nconsole.info(decoded.message)\n// 'hello world'\n```\n\n## Differences from protobuf.js\n\nThis module uses the internal reader/writer from `protobuf.js` as it is highly optimised and there's no point reinventing the wheel.\n\nIt does have one or two differences:\n\n1. Supports `proto3` semantics only\n2. All 64 bit values are represented as `BigInt`s and not `Long`s (e.g. `int64`, `uint64`, `sint64` etc)\n3. Unset `optional` fields are set on the deserialized object forms as `undefined` instead of the default values\n4. `singular` fields set to default values are not serialized and are set to default values when deserialized if not set - protobuf.js [diverges from the language guide](https://github.com/protobufjs/protobuf.js/issues/1468#issuecomment-745177012) around this feature\n5. `map` fields can have keys of any type - protobufs.js [only supports strings](https://github.com/protobufjs/protobuf.js/issues/1203#issuecomment-488637338)\n6. `map` fields are deserialized as ES6 `Map`s - protobuf.js uses `Object`s\n\n## Extra features\n\n### Limiting the size of repeated/map elements\n\nTo protect decoders from malicious payloads, it's possible to limit the maximum size of repeated/map elements.\n\nYou can either do this at compile time by using the [protons.options](https://github.com/protocolbuffers/protobuf/blob/6f1d88107f268b8ebdad6690d116e74c403e366e/docs/options.md?plain=1#L490-L493) extension:\n\n```protobuf\nmessage MyMessage {\n  // repeatedField cannot have more than 10 entries\n  repeated uint32 repeatedField = 1 [(protons.options).limit = 10];\n\n  // stringMap cannot have more than 10 keys\n  map<string, string> stringMap = 2 [(protons.options).limit = 10];\n}\n```\n\nOr at runtime by passing objects to the `.decode` function of your message:\n\n```TypeScript\nconst message = MyMessage.decode(buf, {\n  limits: {\n    repeatedField: 10,\n    stringMap: 10\n  }\n})\n```\n\n#### Limiting repeating fields of nested messages at runtime\n\nSub messages with repeating elements can be limited in a similar way:\n\n```protobuf\nmessage SubMessage {\n  repeated uint32 repeatedField = 1;\n}\n\nmessage MyMessage {\n  SubMessage message = 1;\n}\n```\n\n```TypeScript\nconst message = MyMessage.decode(buf, {\n  limits: {\n    messages: {\n      repeatedField: 5 // the SubMessage can not have more than 5 repeatedField entries\n    }\n  }\n})\n```\n\n#### Limiting repeating fields of repeating messages at runtime\n\nSub messages defined in repeating elements can be limited by appending `$` to the field name in the runtime limit options:\n\n```protobuf\nmessage SubMessage {\n repeated uint32 repeatedField = 1;\n}\n\nmessage MyMessage {\n  repeated SubMessage messages = 1;\n}\n```\n\n```TypeScript\nconst message = MyMessage.decode(buf, {\n  limits: {\n    messages: 5 // max 5x SubMessages\n    messages$: {\n      repeatedField: 5 // no SubMessage can have more than 5 repeatedField entries\n    }\n  }\n})\n```\n\n#### Limiting repeating fields of map entries at runtime\n\nRepeating fields in map entries can be limited by appending `$value` to the field name in the runtime limit options:\n\n```protobuf\nmessage SubMessage {\n repeated uint32 repeatedField = 1;\n}\n\nmessage MyMessage {\n  map<string, SubMessage> messages = 1;\n}\n```\n\n```TypeScript\nconst message = MyMessage.decode(buf, {\n  limits: {\n    messages: 5 // max 5x SubMessages in the map\n    messages$value: {\n      repeatedField: 5 // no SubMessage in the map can have more than 5 repeatedField entries\n    }\n  }\n})\n```\n\n### Overriding 64 bit types\n\nBy default 64 bit types are implemented as [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)s.\n\nSometimes this is undesirable due to [performance issues](https://betterprogramming.pub/the-downsides-of-bigints-in-javascript-6350fd807d) or code legibility.\n\nIt's possible to override the JavaScript type 64 bit fields will deserialize to:\n\n```protobuf\nmessage MyMessage {\n  repeated int64 bigintField = 1;\n  repeated int64 numberField = 2 [jstype = JS_NUMBER];\n  repeated int64 stringField = 3 [jstype = JS_STRING];\n}\n```\n\n```TypeScript\nconst message = MyMessage.decode(buf)\n\nconsole.info(typeof message.bigintField) // bigint\nconsole.info(typeof message.numberField) // number\nconsole.info(typeof message.stringField) // string\n```\n\n## Missing features\n\nSome features are missing `OneOf`s, etc due to them not being needed so far in ipfs/libp2p. If these features are important to you, please open PRs implementing them along with tests comparing the generated bytes to `protobuf.js` and `pbjs`.\n\n# Install\n\n```console\n$ npm i protons\n```\n\n# API Docs\n\n- <https://ipfs.github.io/protons/modules/protons.html>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribute\n\nContributions welcome! Please check out [the issues](https://github.com/ipfs/protons/issues).\n\nAlso see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.\n\nPlease be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)\n","publish_time":1628697586486,"_cnpm_publish_time":1628697586486,"dist-tags":{"latest":"10.0.6"}}