ipns
ipns record definitions
Last updated 3 years ago by achingbrain .
Apache-2.0 OR MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install ipns 
SYNC missed versions from official npm registry.

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.create(privateKey, value, sequenceNumber, lifetime)

Validate record

import * as ipns from 'ipns'

await ipns.validate(publicKey, marshalledData)
// if no error thrown, the record is valid

Embed public key to record

import * as ipns from 'ipns'

const ipnsRecordWithEmbeddedPublicKey = await ipns.embedPublicKey(publicKey, ipnsRecord)

Extract public key from record

import * as ipns from 'ipns'

const publicKey = await ipns.extractPublicKey(peerId, ipnsRecord)

Datastore key

import * as ipns from 'ipns'

ipns.getLocalKey(peerId)

Returns a key to be used for storing the IPNS record locally, that is:

/ipns/${base32(<HASH>)}

Marshal data with proto buffer

import * as ipns from 'ipns'

const ipnsRecord = await ipns.create(privateKey, value, sequenceNumber, lifetime)
// ...
const marshalledData = ipns.marshal(ipnsRecord)
// ...

Returns the record data serialized.

Unmarshal data from proto buffer

import * as ipns from 'ipns'

const ipnsRecord = ipns.unmarshal(storedData)

Returns the IPNSRecord after being deserialized.

Validator

import * as ipns from 'ipns'

const validator = ipns.validator

Contains an object with validate (marshalledData, key) and select (dataA, dataB) functions.

The validate async function aims to verify if an IPNS record is valid. First the record is unmarshalled, then the public key is obtained and finally the record is validated (signatureV2 of CBOR data is verified).

The select function is responsible for deciding which IPNS record is the best (newer) between two records. Both records are unmarshalled and their sequence numbers are compared. If the first record provided is the newer, the operation result will be 0, otherwise the operation result will be 1.

API

Create record


ipns.create(privateKey, value, sequenceNumber, lifetime, options)

Create an IPNS record for being stored in a protocol buffer.

  • privateKey (PrivateKey): key to be used for cryptographic operations.
  • value (string): IPFS path of the object to be published.
  • sequenceNumber (Number): number representing the current version of the record.
  • lifetime (Number): lifetime of the record (in milliseconds).
  • options (CreateOptions): additional creation options.

Returns a Promise that resolves to an object with a IPNSRecord.

Validate record

ipns.validate(publicKey, ipnsRecord)

Validate an IPNS record previously stored in a protocol buffer.

  • publicKey (PublicKey): key to be used for cryptographic operations.
  • ipnsRecord (IPNSRecord): IPNS record (obtained using the create function).

Returns a Promise, which may be rejected if the validation was not successful.

Marshal data with proto buffer

const marshalledData = ipns.marshal(ipnsRecord)

Returns the serialized IPNS record.

  • ipnsRecord (IPNSRecord): ipns record (obtained using the create function).

Unmarshal data from proto buffer

const data = ipns.unmarshal(storedData)

Returns a IPNSRecord after being serialized.

  • storedData (Uint8Array): ipns record serialized.

Extract public key from record

const publicKey = await ipns.extractPublicKey(peerId, ipnsRecord)

Extract a public key from an IPNS record.

  • peerId (PeerId): peer identifier object.
  • ipnsRecord (IPNSRecord): ipns record (obtained using the create function).

Returns a Promise which resolves to public key (PublicKey ): may be used for cryptographic operations.

Namespace

Namespace constants for records.

ipns.namespace

// '/ipns/'
ipns.namespaceLength

// 6

API Docs

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.

Current Tags

  • 0.2.2                                ...           beta (6 years ago)
  • 10.0.0                                ...           latest (2 months ago)

81 Versions

  • 10.0.0                                ...           2 months ago
  • 9.1.2                                ...           2 months ago
  • 9.1.1                                ...           2 months ago
  • 9.1.0                                ...           7 months ago
  • 9.0.0                                ...           10 months ago
  • 8.0.4                                ...           10 months ago
  • 8.0.3                                ...           10 months ago
  • 8.0.2                                ...           10 months ago
  • 8.0.1                                ...           10 months ago
  • 8.0.0                                ...           a year ago
  • 7.0.2                                ...           a year ago
  • 7.0.1                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 6.0.7                                ...           a year ago
  • 6.0.6                                ...           a year ago
  • 6.0.5                                ...           a year ago
  • 6.0.4                                ...           a year ago
  • 6.0.3                                ...           a year ago
  • 6.0.2                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           2 years ago
  • 5.0.2                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.16.0                                ...           3 years ago
  • 0.15.1                                ...           3 years ago
  • 0.15.0                                ...           3 years ago
  • 0.14.2                                ...           3 years ago
  • 0.14.1                                ...           3 years ago
  • 0.14.0                                ...           3 years ago
  • 0.13.4                                ...           3 years ago
  • 0.13.3                                ...           3 years ago
  • 0.13.2                                ...           3 years ago
  • 0.13.1                                ...           3 years ago
  • 0.13.0                                ...           3 years ago
  • 0.12.0                                ...           3 years ago
  • 0.11.0                                ...           4 years ago
  • 0.10.2                                ...           4 years ago
  • 0.10.1                                ...           4 years ago
  • 0.10.0                                ...           4 years ago
  • 0.9.1                                ...           4 years ago
  • 0.9.0                                ...           4 years ago
  • 0.8.2                                ...           4 years ago
  • 0.8.1                                ...           4 years ago
  • 0.8.0                                ...           4 years ago
  • 0.7.4                                ...           4 years ago
  • 0.7.3                                ...           4 years ago
  • 0.7.2                                ...           5 years ago
  • 0.7.1                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.1                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.2                                ...           5 years ago
  • 0.5.1                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.4.5                                ...           6 years ago
  • 0.4.4                                ...           6 years ago
  • 0.4.3                                ...           6 years ago
  • 0.4.2                                ...           6 years ago
  • 0.4.1                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.2.3                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.6                                ...           6 years ago
  • 0.1.5                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (12)
Dev Dependencies (7)

© 2010 - cnpmjs.org x YWFE | Home | YWFE