import { type IPNSPublishTarget } from '@wovin/core/ipns'; import { type StorageConnector } from '@wovin/core/pubsub'; import type { BlockStoreish } from '@wovin/core/ipfs'; import type { ISigner } from 'iso-signatures/types'; import { CID } from 'multiformats'; import { resolveIPNS, retrieveThread } from './retrieve.ts'; import { type BlockStoreForPull, type CarMirrorProgress, type DagLinkCache } from './car-mirror.ts'; import { SignedDelegation } from './types.ts'; import { ClassFields, ParametersExceptFirst } from './utils.ts'; export * from './retrieve.ts'; export * from './store.ts'; export * from './publish.ts'; export * from './delegation.ts'; export * from './types.ts'; export type { BlockStoreForPull, CarMirrorProgress, DagLinkCache } from './car-mirror.ts'; export { createDagLinkCache } from './car-mirror.ts'; /** * Storage connector using UCAN delegation spec for authorization. * * Authorization flow: * 1. init() creates a parent delegation from issuerKey to a temporary key * 2. storeCar() creates a request delegation from tmpKey to service, with parent as proof * 3. The delegation chain is sent in HTTP headers for server validation */ export declare class UcanStoreProxyConnector implements StorageConnector { baseUrl: string; private issuerKey; private tmpKey; private delegations; gatewayBaseUrl: string; nameBaseUrl: string; /** * Initialize a new connector with parent delegations. * * Creates delegations from the issuer key to a temporary key for all storage commands. * The temporary key is used to create request-specific delegations. */ static init({ url, issuerKey, delegations, ...restConfig }: Partial>> & { url: string; issuerKey: ISigner; delegations?: SignedDelegation[]; }): Promise; /** Per-attempt timeout for storeCar (ms). Defaults to the package default (10 min floor). */ storeTimeoutMs?: number; /** Number of storeCar retries AFTER the initial attempt (default 2 => 3 attempts total). */ storeRetries?: number; /** Delay between storeCar retry attempts (ms). Default: 500. */ storeRetryDelayMs?: number; constructor(baseUrl: string, issuerKey: ISigner, tmpKey: ISigner, delegations?: SignedDelegation[], gatewayBaseUrl?: string, nameBaseUrl?: string); get isSetup(): boolean; get isValid(): boolean; /** * Store a CAR file with UCAN authorization. * * Creates a request delegation from tmpKey to service with the store command, * using the parent delegation as proof of authority. */ storeCar(car: Blob, signal?: AbortSignal): Promise>; /** * Push a DAG to the server using car-mirror protocol. * * Lazily walks the DAG from the blockStore, using bloom filters * to skip blocks the server already has. */ pushDag(rootCid: CID, blockStore: BlockStoreish, opts?: { signal?: AbortSignal; onProgress?: (progress: CarMirrorProgress) => void; /** * Root CID of the last snapshot this server is known to already have (e.g. the * previous successful push's rootCid for this thread) — NOT this push's own * rootCid. Lets the sender skip that subtree instead of re-walking the whole DAG. * Safe to omit or pass a stale/wrong value — the server self-corrects in round 2 * at the cost of one extra round-trip. See CarMirrorOptions.prevBoundary. */ prevBoundary?: CID; }): Promise; /** * Pull a DAG from the server using car-mirror protocol. * * Incrementally fetches only blocks the local store doesn't have, * verifying and storing them directly into the provided blockStore. */ pullDag(rootCid: CID, blockStore: BlockStoreForPull, opts?: { signal?: AbortSignal; onProgress?: (progress: CarMirrorProgress) => void; /** * Root CID of the last snapshot already fully present locally (e.g. the * subscription's lastCID) — stops the local want-discovery walk at the * boundary instead of re-walking the whole history. Safe to omit or pass * a stale value. See CarMirrorOptions.prevBoundary. */ prevBoundary?: CID; /** Cross-call local-store-walk memoization. See CarMirrorOptions.dagLinkCache. */ dagLinkCache?: DagLinkCache; }): Promise; retrieveCar(cid: CID): Promise; retrieveThread(...args: ParametersExceptFirst): Promise<{ cid: CID; thread: import("@wovin/core/thread").ThreadInMemory; encryptedCount: number; }>; resolveIPNS(...args: ParametersExceptFirst): Promise>; /** * Publish an IPNS record with UCAN authorization. * * Creates a request delegation from tmpKey to service with the ipns/publish command, * using the parent delegation as proof of authority. */ publishIPNS(ipnsKey: string, recordBase64: string): Promise; /** * Return an IPNSPublishTarget adapter for use with publishIPNSRecord(). * * The adapter publishes IPNS records to `baseUrl` (the Kubo-backed storage * proxy) via UCAN delegation and resolves the current sequence number from * the server at `baseUrl`. Sequence resolution uses a GET to * `${baseUrl}/name/${ipnsName}`, parsing the raw record's sequence field. * If the server returns a 404 or no record, `null` is returned and the * caller (e.g. `publishIPNSRecord`) starts from sequence 0n. * * Because resolution is server-truth, this target alone provides monotonic * sequences across restarts and devices. Core's sequence-coherence retry * (in `publishIPNSRecord`) handles any race conditions by bumping and * retrying on conflict. */ asIPNSTarget(): IPNSPublishTarget; } /** * Publish a snapshot CID to IPNS via a UcanStoreProxyConnector. * * This is the standard way to publish a snapshot root CID after storing its * CAR blob. It signs the IPNS record with the given key and publishes it * to the connector's base URL (the Kubo-backed storage proxy). Sequence * numbers are resolved server-side so the connector target alone provides * monotonicity across devices; core's coherence retry handles any races. * * Previously each app duplicated this logic (localStorage sequence tracking, * zt.ax target assembly, etc.). This shared helper replaces all of them. * * @param cid - The root CID of the snapshot to publish. * @param ipnsKey - The raw Ed25519 private key bytes for IPNS signing. * @param connector - The storage connector (publishes to its `baseUrl`). * @returns The signed IPNS record, including the sequence used. */ export declare function publishSnapshotToIpns(cid: CID, ipnsKey: Uint8Array, connector: UcanStoreProxyConnector): Promise; //# sourceMappingURL=index.d.ts.map