ipns
v10.0.2
Published
IPNS record definitions
Downloads
65,586
Readme
ipns
IPNS Record definitions
Table of contents
Install
$ npm i ipns
Browser <script>
tag
Loading this module through a script tag will make it's exports available as Ipns
in the global namespace.
<script src="https://unpkg.com/ipns/dist/index.min.js"></script>
This module contains all the necessary code for creating, understanding and validating IPNS records.
Usage
Create record
import * as ipns from 'ipns'
const ipnsRecord = await ipns.createIPNSRecord(privateKey, value, sequenceNumber, lifetime)
Validate record against public key
import { validate } from 'ipns/validator'
await validate(publicKey, marshalledRecord)
// if no error thrown, the record is valid
Validate record against routing key
This is useful when validating IPNS names that use RSA keys, whose public key is embedded in the record (rather than in the routing key as with Ed25519).
import { ipnsValidator } from 'ipns/validator'
await ipnsValidator(routingKey, marshalledRecord)
Extract public key from record
import * as ipns from 'ipns'
const publicKey = await ipns.extractPublicKeyFromIPNSRecord(peerId, ipnsRecord)
Marshal data with proto buffer
import * as ipns from 'ipns'
const ipnsRecord = await ipns.createIPNSRecord(privateKey, value, sequenceNumber, lifetime)
// ...
const marshalledData = ipns.marshalIPNSRecord(ipnsRecord)
// ...
Returns the record data serialized.
Unmarshal data from proto buffer
import * as ipns from 'ipns'
const ipnsRecord = ipns.unmarshalIPNSRecord(storedData)
Returns the IPNSRecord
after being deserialized.
API Docs
Namespace
Namespace constants for records.
ipns.namespace
// '/ipns/'
ipns.namespaceLength
// 6
License
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
Contribute
Contributions welcome! Please check out the issues.
Also see our contributing document for more information on how we work, and about contributing in general.
Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
Unless 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.