{"name":"@libp2p/interface-record","version":"2.0.7-1c6702c8","description":"Record interface for libp2p","license":"Apache-2.0 OR MIT","homepage":"https://github.com/libp2p/js-libp2p/tree/master/packages/interface-record#readme","repository":{"type":"git","url":"git+https://github.com/libp2p/js-libp2p.git"},"bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"keywords":["interface","libp2p"],"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"eslintConfig":{"extends":"ipfs","parserOptions":{"sourceType":"module"}},"release":{"branches":["master"],"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"breaking":true,"release":"major"},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"]},"scripts":{"clean":"aegir clean","lint":"aegir lint","dep-check":"aegir dep-check","build":"aegir build","release":"aegir release"},"dependencies":{"@libp2p/interface-peer-id":"2.0.2-1c6702c8","uint8arraylist":"^2.4.3"},"devDependencies":{"aegir":"^39.0.5"},"typedoc":{"entryPoint":"./src/index.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","readmeFilename":"README.md","gitHead":"1c6702c8a48a25e97910c0821f748802edf9ac42","_id":"@libp2p/interface-record@2.0.7-1c6702c8","_nodeVersion":"18.16.0","_npmVersion":"8.19.4","dist":{"integrity":"sha512-0eDuHrt8QIYHvNFmG3v2ri97h0qZnlDHlmYcrr1d2OHdEmpObrzsX3m1bBhgJVX+fNoHctpUxY0+mtyxDR4L+g==","shasum":"44f6765f2213c0cae760e14a435316070bf07420","tarball":"http://registry-npm.ywwl.com/@libp2p/interface-record/download/@libp2p/interface-record-2.0.7-1c6702c8.tgz","fileCount":9,"unpackedSize":10908,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBGRqzQ/msZmkU7kbFWKa/C/2dl5Ux8TNWTNOm3EqLnkAiA59bx/vVlUNuUX3e46mbbmX9kwrkmlLKTpmfnBrfmX3w=="}],"size":3927,"noattachment":false,"key":"/@libp2p/interface-record/-/@libp2p/interface-record-2.0.7-1c6702c8.tgz"},"_npmUser":{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@protocol.ai"},"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"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/interface-record_2.0.7-1c6702c8_1686816670075_0.6465759443173555"},"_hasShrinkwrap":false,"publish_time":1686816670303,"_cnpm_publish_time":1686816670303,"dist-tags":{"latest":"2.0.7","next":"2.0.7-d853d124"}}