helia
    Preparing search index...

    Interface IPNS

    interface IPNS {
        routers: IPNSRouting[];
        import(
            key:
                | string
                | MultihashDigest<number>
                | PublicKey
                | CID<unknown, 114, number, Version>,
            record: IPNSEntry | Uint8Array<ArrayBufferLike>,
            options?: AbortOptions,
        ): Promise<void>;
        publish(
            keyName: string,
            value:
                | string
                | MultihashDigest<number>
                | CID<unknown, number, number, Version>
                | PublicKey,
            options?: PublishOptions,
        ): Promise<IPNSPublishResult>;
        republish(
            key:
                | string
                | MultihashDigest<number>
                | PublicKey
                | CID<unknown, 114, number, Version>,
            options?: RepublishOptions,
        ): Promise<RepublishResult>;
        resolve(
            name:
                | string
                | MultihashDigest<number>
                | PublicKey
                | CID<unknown, 114, number, Version>,
            options?: IPNSResolveOptions,
        ): AsyncGenerator<IPNSResolveResult>;
        unpublish(
            key:
                | string
                | MultihashDigest<number>
                | PublicKey
                | CID<unknown, 114, number, Version>,
            options?: UnpublishOptions,
        ): Promise<void>;
    }
    Index
    routers: IPNSRouting[]

    Configured routing subsystems used to publish/resolve IPNS names

    • Import an existing IPNS record into the local store without publishing it.

      The record is validated and stored so this node serves it on a GET, but it is not broadcast to the routers. A newly imported record (for a key with no existing upkeep policy) is not automatically republished; call republish with an upkeep policy to start keeping it alive.

      Overwrites an older record already stored under this key, or rejects with RecordObsoleteError if the stored record is newer. Importing never changes the key's upkeep metadata, so a key that already has an upkeep policy keeps it and continues to be republished automatically.

      Parameters

      Returns Promise<void>

      (or another validation error) when the record fails validation

      when the stored record is more suitable than the one being imported

    • Creates and publishes an IPNS record that will resolve the passed value signed by a key stored in the libp2p keychain under the passed key name.

      If the key does not exist, a new Ed25519 key will be created. To use a different key types, ensure the key is created and stored in the keychain before invoking this method.

      It is possible to create a recursive IPNS record by passing:

      • A CID with the libp2p-key codec
      • A Multihash
      • A string IPNS key (e.g. /ipns/Qmfoo)

      Parameters

      Returns Promise<IPNSPublishResult>

      import { createHelia } from 'helia'
      import { ipns } from '@helia/ipns'

      const helia = await createHelia()
      const name = ipns(helia)

      const result = await name.publish('my-key-name', cid, {
      signal: AbortSignal.timeout(5_000)
      })

      console.info(result) // { record, name, publicKey }
    • Stop automatically republishing an IPNS record

      By default this removes only the republishing metadata, keeping the record in the datastore so it is still served until it expires. Pass removeRecord: true to also delete the record so the node stops serving it. If a key name is passed, the key remains in the keychain.

      Parameters

      Returns Promise<void>