import { GetUserAgentOptions } from "@fedify/vocab-runtime"; import { MeterProvider, TracerProvider } from "@opentelemetry/api"; //#region src/jrd.d.ts /** * Describes a resource. See also * [RFC 7033 section 4.4](https://datatracker.ietf.org/doc/html/rfc7033#section-4.4). */ interface ResourceDescriptor { /** * A URI that identifies the entity that this descriptor describes. */ readonly subject?: string; /** * URIs that identify the same entity as the `subject`. */ readonly aliases?: readonly string[]; /** * Conveys additional information about the `subject` of this descriptor. */ readonly properties?: Readonly>; /** * Links to other resources. */ readonly links?: readonly Link[]; } /** * Represents a link. See also * [RFC 7033 section 4.4.4](https://datatracker.ietf.org/doc/html/rfc7033#section-4.4.4). */ interface Link { /** * The link's relation type, which is either a URI or a registered relation * type (see [RFC 5988](https://datatracker.ietf.org/doc/html/rfc5988)). */ readonly rel: string; /** * The media type of the target resource (see * [RFC 6838](https://datatracker.ietf.org/doc/html/rfc6838)). */ readonly type?: string; /** * A URI pointing to the target resource. */ readonly href?: string; /** * Human-readable titles describing the link relation. If the language is * unknown or unspecified, the key is `"und"`. */ readonly titles?: Readonly>; /** * Conveys additional information about the link relation. */ readonly properties?: Readonly>; /** * A URI Template (RFC 6570) that can be used to construct URIs by * substituting variables. Used primarily for subscription endpoints * where parameters like account URIs need to be dynamically inserted. * @since 1.9.0 */ readonly template?: string; } //#endregion //#region src/lookup.d.ts /** * The terminal classification of an outgoing {@link lookupWebFinger} call, * recorded as the `webfinger.lookup.result` attribute on the * `webfinger.lookup` counter and `webfinger.lookup.duration` histogram. * * - `found`: the lookup returned a {@link ResourceDescriptor}. * - `not_found`: the remote responded with HTTP `404 Not Found` or * `410 Gone`. Recorded together with `http.response.status_code`. * - `invalid`: the remote responded with content Fedify could not parse * into a {@link ResourceDescriptor} (JSON parse failure), the * redirect chain exceeded `maxRedirection`, the remote redirected to * a different protocol, or the queried `acct:` resource itself was * malformed. * - `network_error`: no HTTP response was received (the URL was * rejected as a private address, `fetch()` threw, or an `AbortError` * cancelled the request). * - `error`: the remote responded with a non-2xx HTTP response that is * neither `404` nor `410`, or any other unexpected failure bubbled up * from the lookup. * @since 2.3.0 */ type WebFingerLookupResult = "found" | "not_found" | "invalid" | "network_error" | "error"; /** * Options for {@link lookupWebFinger}. * @since 1.3.0 */ interface LookupWebFingerOptions { /** * The options for making `User-Agent` header. * If a string is given, it is used as the `User-Agent` header value. * If an object is given, it is passed to {@link getUserAgent} to generate * the `User-Agent` header value. */ userAgent?: GetUserAgentOptions | string; /** * Whether to allow private IP addresses in the URL. * * Mostly useful for testing purposes. *Do not use this in production.* * * Turned off by default. * @since 1.4.0 */ allowPrivateAddress?: boolean; /** * The maximum number of redirections to follow. * @default `5` * @since 1.8.0 */ maxRedirection?: number; /** * The OpenTelemetry tracer provider. If omitted, the global tracer provider * is used. */ tracerProvider?: TracerProvider; /** * The OpenTelemetry meter provider used to record the `webfinger.lookup` * counter and `webfinger.lookup.duration` histogram. If omitted, no * metric measurements are emitted (the helper is opt-in to avoid * touching the global meter provider for callers that do not use * OpenTelemetry). * @since 2.3.0 */ meterProvider?: MeterProvider; /** * AbortSignal for cancelling the request. * @since 1.8.0 */ signal?: AbortSignal; } /** * Looks up a WebFinger resource. * @param resource The resource URL to look up. * @param options Extra options for looking up the resource. * @returns The resource descriptor, or `null` if not found. * @since 0.2.0 */ declare function lookupWebFinger(resource: URL | string, options?: LookupWebFingerOptions): Promise; //#endregion export { Link, LookupWebFingerOptions, ResourceDescriptor, WebFingerLookupResult, lookupWebFinger };