@fedify/webfinger

中文文档
2.1.32发布于 2026/11/17MITTypeScriptESM + CJS构建来源已验证近 30 天下载 7.7万

WebFinger client library for ActivityPub

原始使用文档
文档目录12 节
  1. Features
  2. Installation
  3. Usage
  4. Looking up a WebFinger resource
  5. Working with the result
  6. Configuration options
  7. API
  8. Functions
  9. Types
  10. Documentation
  11. Related packages
  12. License

@fedify/webfinger: WebFinger client library for ActivityPub

JSR npm

This package provides a WebFinger client implementation for looking up ActivityPub actors and other resources in the fediverse. It is part of the Fedify framework but can be used independently.

Features

  • WebFinger resource lookup (RFC 7033)
  • Support for acct: URI scheme
  • Automatic HTTPS URL construction
  • Configurable redirect handling
  • OpenTelemetry integration for tracing
  • Private IP address validation for security

Installation

deno add jsr:@fedify/webfinger  # Deno
npm add @fedify/webfinger       # npm
pnpm add @fedify/webfinger      # pnpm
yarn add @fedify/webfinger      # Yarn
bun add @fedify/webfinger       # Bun

Usage

Looking up a WebFinger resource

You can look up a WebFinger resource using the lookupWebFinger() function:

import { lookupWebFinger } from "@fedify/webfinger";

// Look up by acct: URI
const result = await lookupWebFinger("acct:[email protected]");

// Look up by URL
const result2 = await lookupWebFinger("https://example.com/users/alice");

Working with the result

The result is a ResourceDescriptor object containing the subject, aliases, properties, and links:

import { lookupWebFinger } from "@fedify/webfinger";

const result = await lookupWebFinger("acct:[email protected]");
if (result != null) {
  console.log("Subject:", result.subject);
  console.log("Aliases:", result.aliases);

  // Find the ActivityPub actor URL
  const actorLink = result.links?.find(
    (link) => link.rel === "self" && link.type === "application/activity+json"
  );
  if (actorLink?.href != null) {
    console.log("Actor URL:", actorLink.href);
  }
}

Configuration options

The lookupWebFinger() function accepts various options:

import { lookupWebFinger } from "@fedify/webfinger";

const result = await lookupWebFinger("acct:[email protected]", {
  // Custom User-Agent header
  userAgent: "MyApp/1.0",

  // Maximum redirects to follow (default: 5)
  maxRedirection: 3,

  // Cancel sooner than the default 10-second lookup deadline
  signal: AbortSignal.timeout(5000),
});

Each lookup has a 10-second deadline across DNS resolution, redirects, and response reading. A supplied signal can end it sooner but cannot extend it.

API

Functions

  • lookupWebFinger(resource, options?): Looks up a WebFinger resource and returns a ResourceDescriptor or null if not found.

Types

  • ResourceDescriptor: Describes a WebFinger resource with subject, aliases, properties, and links.
  • Link: Represents a link in a WebFinger response with relation type, media type, href, titles, and properties.
  • LookupWebFingerOptions: Options for the lookupWebFinger() function.

Documentation

For comprehensive documentation, please refer to:

  • @fedify/fedify: The main Fedify framework
  • @fedify/vocab: Activity Vocabulary library

License

MIT License

版本与发布记录

@fedify/webfinger 共发布 546 个版本,首次发布于 2026/01/12;过去 12 个月发布了 546 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.32latest2026/11/17今天
2.0.362026/11/17今天
2.3.16-dev.28452026/11/17今天
2.5.0-dev.28442026/11/17今天
2.0.36-dev.28432026/11/17今天
2.3.16-dev.28412026/11/17今天

其他发布通道:pr-559 → 2.0.0-pr.559.6,pr-633 → 2.0.6-pr.633.9,pr-639 → 2.0.7-pr.639.14,pr-697 → 2.2.0-pr.697.18,pr-708 → 2.2.0-pr.708.19,pr-709 → 2.2.0-pr.709.20。

关于 @fedify/webfinger 的常见问题

@fedify/webfinger 是什么?

WebFinger client library for ActivityPub

如何安装 @fedify/webfinger?

在项目目录运行 npm install @fedify/webfinger,或使用 pnpm add / yarn add / bun add。

@fedify/webfinger 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fedify/webfinger 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fedify/webfinger 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fedify/webfinger 可以商用吗?

@fedify/webfinger 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fedify/webfinger 的下载量有多少?

根据 npm 官方下载统计,@fedify/webfinger 在 2026/10/15 – 2026/11/13 这 30 天内被下载 76,896 次,日均约 2,563 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fedify/webfinger 还在维护吗?

最新版本 2.1.32 发布于 2026/11/17(今天);至今共发布 546 个版本,其中过去 12 个月发布了 546 个;首次发布于 2026/01/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。