ipns
ipns record definitions
Last updated 7 years ago by vascosantos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ipns 
SYNC missed versions from official npm registry.

ipns

ipfs.tech Discuss codecov CI

IPNS record definitions

About

Implements parsing and serialization of IPNS Records.

Example - Create record

import { createIPNSRecord } from 'ipns'
import { generateKeyPair } from '@libp2p/crypto/keys'

const privateKey = await generateKeyPair('Ed25519')
const value = 'hello world'
const sequenceNumber = 0
const lifetime = 3_600_000 // ms, e.g. one hour

const ipnsRecord = await createIPNSRecord(privateKey, value, sequenceNumber, lifetime)

Example - Validate record against public key

import { validate } from 'ipns/validator'
import { generateKeyPair } from '@libp2p/crypto/keys'

const privateKey = await generateKeyPair('Ed25519')
const publicKey = privateKey.publicKey
const marshalledRecord = Uint8Array.from([0, 1, 2, 3])

await validate(publicKey, marshalledRecord)
// if no error thrown, the record is valid

Example - 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'
import { multihashToIPNSRoutingKey } from 'ipns'
import { generateKeyPair } from '@libp2p/crypto/keys'

const privateKey = await generateKeyPair('Ed25519')
const routingKey = multihashToIPNSRoutingKey(privateKey.publicKey.toMultihash())
const marshalledRecord = Uint8Array.from([0, 1, 2, 3])

await ipnsValidator(routingKey, marshalledRecord)

Example - Extract public key from record

import { extractPublicKeyFromIPNSRecord, createIPNSRecord } from 'ipns'
import { generateKeyPair } from '@libp2p/crypto/keys'

const privateKey = await generateKeyPair('Ed25519')
const record = await createIPNSRecord(privateKey, 'hello world', 0, 3_600_000)

const publicKey = await extractPublicKeyFromIPNSRecord(record)

Example - Marshal data with proto buffer

import { createIPNSRecord, marshalIPNSRecord } from 'ipns'
import { generateKeyPair } from '@libp2p/crypto/keys'

const privateKey = await generateKeyPair('Ed25519')
const record = await createIPNSRecord(privateKey, 'hello world', 0, 3_600_000)
// ...
const marshalledData = marshalIPNSRecord(record)
// ...

Returns the record data serialized.

Example - Unmarshal data from proto buffer

import { unmarshalIPNSRecord } from 'ipns'

const storedData = Uint8Array.from([0, 1, 2, 3, 4])
const ipnsRecord = unmarshalIPNSRecord(storedData)

Returns the IPNSRecord after being deserialized.

Install

$ npm i ipns

Browser <script> tag

Loading this module through a script tag will make its exports available as Ipns in the global namespace.

<script src="https://unpkg.com/ipns/dist/index.min.js"></script>

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 (7 years ago)
  • 10.1.6                                ...           latest (17 hours ago)

90 Versions

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

Copyright 2013 - present © cnpmjs.org | Home |