Skip to content

feat: republish third-party ipns record - #891

Open
tabcat wants to merge 8 commits into
ipfs:mainfrom
tabcat:feat/refresh-record
Open

feat: republish third-party ipns record#891
tabcat wants to merge 8 commits into
ipfs:mainfrom
tabcat:feat/refresh-record

Conversation

@tabcat

@tabcat tabcat commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Title

feat: republish third-party ipns record

Description

Adds the ability to keep alive an IPNS record this node did not originally
publish, plus the upkeep-policy machinery around it.

New methods on the IPNS interface:

  • import(key, record): validate a record and store it locally without touching
    the network. No metadata is written, so the record is served on a GET but
    dormant until republish gives it an upkeep policy.
  • republish(key, options): republish the record held locally for a key. It
    compares the local record against the network with ipnsSelector, throws
    RecordObsoleteError if a newer record is already published, otherwise
    persists the chosen upkeep policy and publishes. Best-effort on the network (a
    failing network router does not throw; use onProgress and the logs), but a
    local-store persist failure throws, since that write saves the upkeep policy.
  • unpublish(key, options): stop republishing. By default it removes only the
    metadata (the record stays served until it expires); removeRecord: true also
    deletes the record.

Upkeep policy (stored per key in the metadata, default reissue):

  • reissue: re-sign the record with a new sequence and validity. Needs the
    signing key, so only publish can select it.
  • rebroadcast: re-put the existing record as-is. The background loop resolves
    the network's latest record first and adopts a newer one instead of pushing a
    stale copy.
  • none: no upkeep.

Other changes:

  • resolve skips the local store when nocache is set, and honors
    validate: false on the network path.
  • The validator rejects a record whose embedded (non-identity) public key does
    not hash to its routing key.

The metadata Upkeep enum replaces the earlier refresh bool; its values are
reissue / rebroadcast / none.

Closes #877

Notes & open questions

  • publish() is all-or-nothing (a single router failure fails the publish)
    while republish() is best-effort on the network.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@tabcat
tabcat marked this pull request as ready for review October 31, 2025 01:48
@tabcat
tabcat requested a review from a team as a code owner October 31, 2025 01:48
@gammazero

Copy link
Copy Markdown

Triage: in review

@Verity-Freedom

Copy link
Copy Markdown

сс @lidel for awareness
cc @tabcat for awareness

@hsanjuan

Copy link
Copy Markdown

Triage:

@tabcat
tabcat marked this pull request as draft January 31, 2026 11:57
@tabcat

tabcat commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Turning this back into a draft. There should be a way to create a new record without publishing or republishing to public routers as part of this PR.

@tabcat

tabcat commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

I've replaced the refresh bool field (from this pr) of the metadata protobuf for localStore with an Upkeep enum with properties republish, refresh, and none currently. The publish and republish methods now have an upkeep option with type 'republish' | 'refresh' | 'none'. 'republish' is only availabe for publish as it requires the key to sign new ttl.

Comment thread packages/ipns/src/index.ts Outdated
Comment thread packages/ipns/src/pb/metadata.proto Outdated
@tabcat

tabcat commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

this still needs some work. ill convert to ready when its ready for review.

Comment thread packages/ipns/src/ipns/republisher.ts Outdated
@tabcat
tabcat marked this pull request as ready for review April 19, 2026 14:44
@tabcat
tabcat requested a review from achingbrain April 19, 2026 14:44
@achingbrain achingbrain changed the title feat: refresh ipns record feat: republish third-party ipns record Jun 17, 2026
@tabcat
tabcat marked this pull request as draft June 17, 2026 17:12
tabcat added 8 commits August 24, 2026 04:20
Adds the Upkeep enum (reissue/rebroadcast/none) plus keyName/lifetime fields to the stored IPNS record metadata, and a RecordObsoleteError that carries the more suitable record.
Adds routerName and isLocalStoreRouting helpers and an overwrite put option to the routing module, and makes the validator reject a record whose embedded non-identity public key does not hash to its routing key.
Adds a metadata merge that preserves keyName/lifetime on partial updates, tolerant metadata reads, a list method, and deleteMetadata.
Extracts the network-router query into a reusable findRoutingRecords helper, skips the local store on nocache, and honors validate:false on the network path.
publish stores an upkeep policy (default reissue). unpublish removes only the republishing metadata by default (keeping the record), with a removeRecord option to also delete the record.
Adds import (validate and store a record locally without publishing), republish (publish the local record, backing off if the routing has a newer one, best-effort on the network), and the background loop that reissues or rebroadcasts due records, adopting a newer network record when rebroadcasting.
Wires import/republish/unpublish through the IPNS class, adds the UpkeepPolicy, UnpublishOptions, RepublishOptions and RepublishResult types, and normalizeKeyName for unpublish.
Adds a republish example to the README and a dictionary entry.
@tabcat
tabcat force-pushed the feat/refresh-record branch from cb409cc to 609b594 Compare August 24, 2026 09:22
@tabcat
tabcat marked this pull request as ready for review August 24, 2026 09:24
@tabcat

tabcat commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

I'm pretty happy with where this is at now. I've updated the description to give a pretty good idea of whats changed.

I did change the behavior of unpublish to not remove the record by default, just the metadata which sets the upkeep. I think this is the correct behavior because deleting the record loses the record sequence number. I've added an option removeRecord for the case where the user actually wants to remove the record. Not sure if this would be considered a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: @helia/ipns republish specific existing records

5 participants