Skip to content
/ js-ipns Public

Utilities for creating, parsing, and validating IPNS records

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

ipfs/js-ipns

Repository files navigation

ipns

ipfs.tech Discuss codecov CI

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

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.

About

Utilities for creating, parsing, and validating IPNS records

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published