/**
 * Shared types and utilities for the `dwn://connect` discovery protocol.
 *
 * The payload is the JSON data exchanged between the local DWN server
 * (electrobun-dwn) and the requesting app during the `dwn://connect`
 * redirect flow. It is encoded as base64url and placed in the URL
 * fragment (`#`) of the callback URL.
 *
 * This module intentionally avoids external dependencies so it can be
 * consumed from any environment (Bun, browser, Electrobun) without
 * triggering transitive dependency resolution issues.
 *
 * @module
 */
/**
 * The JSON payload delivered via the URL fragment in a `dwn://connect`
 * callback redirect.
 *
 * Intentionally minimal — everything beyond the endpoint (version,
 * WebSocket support, etc.) is obtained from `GET {endpoint}/info`.
 */
export type DwnDiscoveryPayload = {
    /** Base URL of the running DWN server (e.g. `"http://127.0.0.1:55557"`). */
    endpoint: string;
};
/**
 * Parsed result from a `dwn://connect` URL.
 */
export type DwnConnectUrlParams = {
    /** The callback URL to redirect to with the discovery payload. */
    callback: string;
};
/** The URL scheme for DWN discovery protocol handlers. */
export declare const DWN_PROTOCOL_SCHEME = "dwn";
/** The `dwn://connect` path that triggers the discovery handshake. */
export declare const DWN_CONNECT_PATH = "connect";
/**
 * Build a `dwn://connect?callback=<url>` URL that, when opened by the OS,
 * triggers electrobun-dwn (or another `dwn://` scheme handler) to redirect
 * back to `callbackUrl` with the local DWN endpoint in the URL fragment.
 *
 * This is the **trigger** side of the `dwn://connect` browser flow.
 * The web app opens this URL (e.g. via `window.open()` or `location.href`),
 * the OS routes it to the registered handler, and the handler redirects
 * back with the discovery payload.
 *
 * @param callbackUrl - The URL to redirect back to after discovery.
 *   This should be the current page (or a dedicated callback page) that
 *   will read the payload from `window.location.hash`.
 * @returns The `dwn://connect?callback=<encoded-url>` URL string.
 *
 * @example
 * ```ts
 * const registerUrl = buildDwnConnectUrl('https://myapp.com/callback');
 * // => 'dwn://connect?callback=https%3A%2F%2Fmyapp.com%2Fcallback'
 * window.open(registerUrl);
 * ```
 */
export declare function buildDwnConnectUrl(callbackUrl: string): string;
/**
 * Encode a {@link DwnDiscoveryPayload} as a base64url string suitable
 * for use in a URL fragment.
 *
 * @param payload - The discovery payload to encode.
 * @returns A base64url-encoded string (no padding).
 */
export declare function encodeDwnDiscoveryPayload(payload: DwnDiscoveryPayload): string;
/**
 * Decode a base64url-encoded string back into a {@link DwnDiscoveryPayload}.
 *
 * @param encoded - The base64url string from the URL fragment.
 * @returns The parsed payload, or `undefined` if decoding or parsing fails.
 */
export declare function decodeDwnDiscoveryPayload(encoded: string): DwnDiscoveryPayload | undefined;
/**
 * Parse a `dwn://connect?callback=<url>` URL into its components.
 *
 * @param url - The full `dwn://connect?callback=...` URL.
 * @returns The parsed parameters, or `undefined` if the URL is not a
 *   valid `dwn://connect` URL or is missing the `callback` parameter.
 */
export declare function parseDwnConnectUrl(url: string): DwnConnectUrlParams | undefined;
/**
 * Build the full callback redirect URL with the discovery payload
 * encoded in the URL fragment.
 *
 * @param callbackUrl - The callback URL from the `dwn://connect` request.
 * @param payload - The discovery payload to encode in the fragment.
 * @returns The full redirect URL (e.g. `https://notes.sh/dwn#eyJ...`).
 */
export declare function buildDwnDiscoveryRedirectUrl(callbackUrl: string, payload: DwnDiscoveryPayload): string;
/**
 * Read a {@link DwnDiscoveryPayload} from a URL's fragment (hash).
 *
 * Intended for use in the browser callback page that receives the
 * redirect from electrobun-dwn.
 *
 * @param url - The full URL including the `#` fragment, or just the
 *   fragment string (with or without the leading `#`).
 * @returns The parsed payload, or `undefined` if the fragment is missing
 *   or contains an invalid payload.
 */
export declare function readDwnDiscoveryPayloadFromUrl(url: string): DwnDiscoveryPayload | undefined;
//# sourceMappingURL=dwn-discovery-payload.d.ts.map