This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
webfinger.js is a WebFinger client library that runs in both browser and Node.js environments. It implements the WebFinger protocol for discovering user information across domains using email-like addresses.
bun run lint # Run ESLint on the codebasebun run build # Compile TypeScript to JavaScript (outputs to .tmp/)bun run test # Run the test suitebun run docs:generate # Generate API documentation from TypeScript/JSDoc
bun run docs:watch # Watch mode for documentation generation- Uses
bunas the package manager (configured in package.json) - Run
bun installto install dependencies
- Main source:
src/webfinger.ts- Single TypeScript file containing the WebFinger class - Output: Compiles to
dist/(UMDwebfinger.cjs, ES modulewebfinger.mjs, browser aliaswebfinger.js, minifiedwebfinger.min.js, andwebfinger.d.tstype definitions) - Tests: Unit tests in
src/webfinger.test.ts; browser, imports, and integration tests inspec/ - Documentation: Auto-generated
docs/api/API.mdfrom TypeScript/JSDoc
The main WebFinger class in src/webfinger.ts implements:
- Constructor: Takes configuration object with options for TLS, fallbacks, timeouts
- Primary Methods:
lookup(address): Main WebFinger lookup functionalitylookupLink(address, rel): Find specific link relations
- Private Methods:
fetchJRD(): HTTP request handler for JSON Resource Descriptor (JRD) responsesprocessJRD(): Processes and indexes WebFinger responses
- Fallback Chain: Supports multiple fallback mechanisms:
- Different URI endpoints (
webfinger,host-meta,host-meta.json) - HTTP fallback from HTTPS
- Different URI endpoints (
LINK_URI_MAPS: Maps WebFinger relation URIs to property namesLINK_PROPERTIES: Defines supported link types (avatar, blog, profile, etc.)URIS: Fallback endpoint order for discovery
The project features:
- Full TypeScript: Source code with comprehensive type definitions
- Exported Types:
WebFingerConfig,WebFingerResult,LinkObject,JRD,WebFingerError - JSDoc Documentation: Comprehensive comments for IDE support and auto-generated docs
- UMD Build System: Uses bun build with custom wrapper for universal compatibility
- Auto-generated:
docs/api/API.mdgenerated from TypeScript/JSDoc using TypeDoc - Single Source of Truth: JSDoc comments in source drive both IDE support and documentation
- Always Current: Documentation regenerated during release process
- TypeScript compiles with full type checking
- Bun build creates optimized ESM bundle
- Custom UMD wrapper adds browser/Node.js compatibility
- Build process adds version logging automatically
- Demo references
dist/webfinger.jsdirectly
- CRITICAL: The
dist/directory should ONLY contain the latest RELEASED version - NEVER update dist during development or testing - it should only be updated during the official release process
- Do not modify build system to update dist when tests run - this pollutes the repository with development artifacts
- Tests should run against source TypeScript files, and compiled dist files
- Prepare Release: Creates release branch with version bump, build, docs generation
- Release Notes: Managed in
CHANGELOG.mdwith manual curation in PR - GitHub Actions: Automated workflows for both prepare and publish steps
- NPM Publishing: Automatic on release PR merge
- Unit tests use Bun testing framework
- Other tests use mocha & chai
- Browser tests are run with web-test-runner
- Both TypeScript and compiled JavaScript are tested
- Tests run against development and release builds
- Two tiers:
bun run test— dev loop (unit + integration + browser). Fast, no dist mutation.bun run test:release— release gate (builds dist/ and runs the full import matrix: Bun ESM, Node ESM, Node CJS viatest:imports). Use this whenever packaging surfaces are touched.
- Import smoke tests live in
spec/imports/{bun,node,node-cjs}/and are aggregated bybun run test:imports
- ALWAYS USE BUN: Never use npm or node commands, always use bun
- ALWAYS LINT AND TEST BEFORE COMMITS: CRITICAL - Run
bun run lintandbun run testbefore ANY commit or push. This is non-negotiable. - USE
test:releaseFOR PACKAGING CHANGES: If you touchpackage.jsonexports,scripts/build.js,tsconfig*.json, or anything that affectsdist/, runbun run test:releasebefore committing. It rebuilds dist and runs the full import matrix. Discard the resultingdist/changes withgit checkout -- dist/before committing (see dist policy). - NEVER UPDATE DIST DURING DEVELOPMENT: The dist/ directory should only contain the latest released version
- Documentation: API docs are auto-generated - update JSDoc in source code
- No proactive README/docs creation: Only create documentation if explicitly requested