import { unmarshalIPNSRecord } from 'ipns'; import type { CID } from 'multiformats/cid'; export interface SignedIPNSRecord { recordBytes: Uint8Array; ipnsName: string; value: string; sequence: bigint; } /** Derive IPNS name string (k51...) from Ed25519 private key bytes */ export declare function ipnsNameFromPrivateKey(privKeyBytes: Uint8Array): string; /** * Create a signed IPNS record (protobuf wire format). * Same bytes can be published to any naming service. */ export declare function createSignedIPNSRecord(privateKey: Uint8Array, cid: CID, sequence: bigint, lifetimeMs?: number): Promise; export { unmarshalIPNSRecord }; /** * A target that can receive a signed IPNS record, advertise its current * sequence, or both. * * - `publish` is called by `publishIPNSRecord` to actually store the record * on the target's backing service. Targets without `publish` are skipped * during the fan-out (e.g. a sequence-only source). * - `resolveSequence` is consulted by `publishIPNSRecord` to compute the * next IPNS sequence. The first target to return a value (including * `null` for "never published") wins. Throw to indicate a transient * error — the caller will try the next target. * * Most real targets (e.g. a storage connector) provide both. A simple * "track sequence in localStorage" target only needs `resolveSequence`. */ export interface IPNSPublishTarget { name: string; publish?(ipnsName: string, recordBytes: Uint8Array): Promise; resolveSequence?(ipnsName: string): Promise; } /** * Resolve the current IPNS sequence from a generic naming service. * Returns null if the name was never published (404). * Throws on network/server errors so the caller can try a different target. */ export declare function resolveIPNSSequence(nameServiceUrl: string, ipnsName: string): Promise; /** * Options for {@link publishIPNSRecord}. */ export interface PublishIPNSRecordOptions { /** * Max number of times to bump the sequence on "existing >= new" conflict. * Defaults to 3. Each bump re-signs the record with a higher sequence * and retries all targets. */ maxSequenceBumps?: number; } /** * Create a signed IPNS record and publish to all configured targets. * * Sequence resolution: walks `targets` in order asking each one with a * `resolveSequence` method. The first target to successfully return a value * (including `null` for "never published") determines the next sequence. * If every target throws or none supports `resolveSequence`, falls back to 0n. * * Publish fan-out: only targets with a `publish` method are called. * Throws if every publish-capable target fails; partial failures are logged. * * **Sequence-coherence retry:** if a publish target rejects with the Kubo * "existing IPNS record has sequence X >= new record sequence Y" error, * the function parses `X`, bumps the sequence to `max(X + 1n, Y + 1n)`, * re-signs the record, and retries (up to `maxSequenceBumps` times). * This is the "increment and clobber" mechanism that recovers from * sequence drift without requiring server-side `--force` support. */ export declare function publishIPNSRecord(privateKey: Uint8Array, cid: CID, targets: IPNSPublishTarget[], options?: PublishIPNSRecordOptions): Promise; //# sourceMappingURL=ipns-record.d.ts.map