{"bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"dist":{"shasum":"3f674476e80c98917793994e5b6db087ceecef88","tarball":"https://registry.npmjs.org/@libp2p/interface-record/-/interface-record-2.0.7-ab0e3980.tgz","fileCount":9,"integrity":"sha512-m71fa4TsvGIwriH5cRKBq7nODEbvxJlC2woo4bfT63p05jWRsKLGkpEugeBERaSXmy9hZIf9AAayDhqwUgjbmg==","signatures":[{"sig":"MEQCIEOT+x3SQqbtCgbkQ+MStW2SWBktt9Tnjb10F4C+2uPsAiAC0+MdIftCt0UaQFY3BPUjgo9+6xDBKU+2Iqbk44AORw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8915},"name":"@libp2p/interface-record","type":"module","types":"./dist/src/index.d.ts","readme":"# @libp2p/interface-record <!-- omit in toc -->\n\n[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)\n[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)\n[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)\n\n> Record interface for libp2p\n\n## Table of contents <!-- omit in toc -->\n\n- [Install](#install)\n- [Usage](#usage)\n- [Create Record](#create-record)\n- [API](#api)\n  - [marshal](#marshal)\n  - [equals](#equals)\n- [API Docs](#api-docs)\n- [License](#license)\n- [Contribution](#contribution)\n\n## Install\n\n```console\n$ npm i @libp2p/interface-record\n```\n\nA libp2p node needs to store data in a public location (e.g. a DHT), or rely on potentially untrustworthy intermediaries to relay information. Libp2p provides an all-purpose data container called **envelope**, which includes a signature of the data, so that it its authenticity can be verified.\n\nThe record represents the data that will be stored inside the **envelope** when distributing records across the network. The `interface-record` aims to guarantee that any type of record created is compliant with the libp2p **envelope**.\n\nTaking into account that a record might be used in different contexts, an **envelope** signature made for a specific purpose **must not** be considered valid for a different purpose. Accordingly, each record has a short and descriptive string representing the record use case, known as **domain**. The data to be signed will be prepended with the domain string, in order to create a domain signature.\n\nA record can also contain a Uint8Array codec (ideally registered as a [multicodec](https://github.com/multiformats/multicodec)). This codec will prefix the record data in the **envelope** , so that it can be deserialized deterministically.\n\n## Usage\n\n```js\nconst tests = require('libp2p-interfaces-compliance-tests/record')\ndescribe('your record', () => {\n  tests({\n    async setup () {\n      return YourRecord\n    },\n    async teardown () {\n      // cleanup resources created by setup()\n    }\n  })\n})\n```\n\n## Create Record\n\n```js\nconst multicodec = require('multicodec')\nconst Record = require('libp2p-interfaces/src/record')\nconst { fromString } = require('uint8arrays/from-string')\n// const Protobuf = require('./record.proto')\n\nconst ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record'\nconst ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = fromString('0301', 'hex')\n\n/**\n * @implements {import('libp2p-interfaces/src/record/types').Record}\n */\nclass PeerRecord {\n  constructor (peerId, multiaddrs, seqNumber) {\n    this.domain = ENVELOPE_DOMAIN_PEER_RECORD\n    this.codec = ENVELOPE_PAYLOAD_TYPE_PEER_RECORD\n  }\n\n  /**\n   * Marshal a record to be used in an envelope.\n   *\n   * @returns {Uint8Array}\n   */\n  marshal () {\n    // Implement and return using Protobuf\n  }\n\n  /**\n   * Returns true if `this` record equals the `other`.\n   *\n   * @param {PeerRecord} other\n   * @returns {other is Record}\n   */\n  equals (other) {\n    // Verify\n  }\n}\n```\n\n## API\n\n### marshal\n\n- `record.marshal()`\n\nMarshal a record to be used in a libp2p envelope.\n\n**Returns**\n\nIt returns a `Protobuf` containing the record data.\n\n### equals\n\n- `record.equals(other)`\n\nVerifies if the other Record is identical to this one.\n\n**Parameters**\n\n- other is a `Record` to compare with the current instance.\n\n**Returns**\n\n- `other is Record`\n\n## API Docs\n\n- <https://libp2p.github.io/js-libp2p/modules/_libp2p_interface_record.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## Contribution\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","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"ab0e3980160dcbacf00825cfc4c6ba1d0c07a20c","license":"Apache-2.0 OR MIT","scripts":{"lint":"aegir lint","build":"aegir build","clean":"aegir clean","dep-check":"aegir dep-check"},"typedoc":{"entryPoint":"./src/index.ts"},"_npmUser":{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@protocol.ai"},"homepage":"https://github.com/libp2p/js-libp2p/tree/master/packages/interface-record#readme","keywords":["interface","libp2p"],"repository":{"url":"git+https://github.com/libp2p/js-libp2p.git","type":"git"},"_npmVersion":"8.19.4","description":"Record interface for libp2p","directories":{},"maintainers":[{"name":"jacobheun","email":"jacobheun@gmail.com"},{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@protocol.ai"},{"name":"alanshaw","email":"alan138@gmail.com"},{"name":"vascosantos","email":"santos.vasco10@gmail.com"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"daviddias","email":"mail@daviddias.me"}],"_nodeVersion":"18.16.0","dependencies":{"uint8arraylist":"^2.4.3","@libp2p/interface-peer-id":"2.0.2-ab0e3980"},"eslintConfig":{"extends":"ipfs","parserOptions":{"sourceType":"module"}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"aegir":"^39.0.10"},"_npmOperationalInternal":{"tmp":"tmp/interface-record_2.0.7-ab0e3980_1687169048213_0.1684439960635522","host":"s3://npm-registry-packages"},"_id":"@libp2p/interface-record@2.0.7-ab0e3980","version":"2.0.7-ab0e3980"}