ipns
    Preparing search index...

    Module index

    Implements parsing and serialization of IPNS Records.

    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)
    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

    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)
    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)
    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.

    import { unmarshalIPNSRecord } from 'ipns'

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

    Returns the IPNSRecord after being deserialized.

    Interfaces

    CreateOptions
    CreateV2Options
    CreateV2OrV1Options
    IDKeys
    IPNSRecordData
    IPNSRecordV1V2
    IPNSRecordV2

    Type Aliases

    IPNSRecord

    Variables

    namespace
    namespaceLength

    Functions

    createIPNSRecord
    createIPNSRecordWithExpiration
    extractPublicKeyFromIPNSRecord
    marshalIPNSRecord
    multihashFromIPNSRoutingKey
    multihashToIPNSRoutingKey
    unmarshalIPNSRecord