Guide for contributing to and developing webfinger.js.
This project uses Bun for development and package management.
- Bun (latest version)
- Git
# Clone the repository
git clone https://github.com/silverbucket/webfinger.js.git
cd webfinger.js
# Install dependencies
bun installFor a complete list of development commands with descriptions, run:
bun run helpAlways use Bun - This project uses Bun as the runtime and package manager. Never use npm or node commands.
# ✅ Correct
bun run test
bun run build
bun install some-package
# ❌ Incorrect
npm test
node build.js
npm install some-packagewebfinger.js/
├── src/
│ └── webfinger.ts # Main TypeScript source
├── dist/
│ ├── webfinger.cjs # CommonJS / UMD bundle
│ ├── webfinger.mjs # ES module bundle
│ ├── webfinger.js # Browser-friendly alias of the UMD bundle
│ ├── webfinger.min.js # Minified UMD bundle for CDN / <script> usage
│ ├── webfinger.d.ts # TypeScript definitions
│ └── webfinger.d.ts.map # Definition source map
├── docs/
│ ├── api/
│ │ └── API.md # Auto-generated API docs (DO NOT EDIT)
│ ├── EXAMPLES.md # Usage examples
│ ├── DEVELOPMENT.md # This file
│ ├── RELEASE.md # Release process guide
│ └── SECURITY.md # Security information
├── demo/
│ └── index.html # Live demo page
├── spec/
│ ├── browser/ # Browser environment tests
│ ├── imports/ # Import method tests (bun, node, node-cjs)
│ └── integration/ # Integration tests (local + real servers)
├── scripts/ # Build and release scripts
└── .github/workflows/ # GitHub Actions
The project uses a custom build system powered by Bun:
- TypeScript Compilation:
tsccompiles TypeScript with type checking - Bundle Creation:
bun buildcreates optimized ESM bundle - UMD Wrapping: Custom script wraps ESM for universal compatibility
- Browser Testing: Built files work in both Node.js and browsers
# The build process:
bun run tsc # TypeScript compilation
bun scripts/build.js # Bundle creation with UMD wrapperTests are organized into two tiers:
Fast feedback while editing source. Runs unit, integration, and browser tests against source and .tmp/ build output.
bun run test # unit + integration + browser
bun run test:unit # Unit tests (TypeScript + JavaScript)
bun run test:integration # Integration tests with real servers
bun run test:browser # Browser environment testsThe authoritative check before shipping. Builds dist/ and runs the full import matrix against the built artifacts, so any regression in package.json exports, bundler output, or module wrappers is caught before release.
bun run test:release # build:release + test + test:imports
bun run test:imports # Bun ESM + Node ESM + Node CJS smoke tests
bun run test:imports:bun # Bun ES module import (spec/imports/bun)
bun run test:imports:node # Node.js ES module import (spec/imports/node)
bun run test:imports:node-cjs # Node.js CommonJS require (spec/imports/node-cjs)Run test:release whenever you touch package.json exports, scripts/build.js, tsconfig*.json, or anything that affects dist/. It mutates dist/ locally — the dist policy still applies, so discard those changes (git checkout -- dist/) before committing.
- Unit tests:
src/webfinger.test.ts— Core functionality testing - Integration tests:
spec/integration/— Real server and local server tests - Browser tests:
spec/browser/— Browser environment compatibility - Import smoke tests:
spec/imports/{bun,node,node-cjs}/— Verify the published package imports cleanly in each supported runtime viafile:/link:againstdist/ - Uses Bun testing framework with comprehensive test coverage
| Runtime | Module system | Test |
|---|---|---|
| Bun | ES modules | test:imports:bun |
| Node.js | ES modules | test:imports:node |
| Node.js | CommonJS (require) |
test:imports:node-cjs |
CI runs the full matrix on every pull request via .github/workflows/compliance.yml; prepare-release.yml runs it again before creating a release PR.
Documentation is auto-generated from TypeScript source code using TypeDoc.
The docs/api/API.md file is auto-generated from JSDoc comments in the TypeScript source.
# ✅ To update documentation:
# 1. Edit JSDoc comments in src/webfinger.ts
# 2. Run: bun run docs:generate
# ❌ Never do this:
# Edit docs/api/API.md directlydocs/api/API.md- Auto-generated API reference (DO NOT EDIT)docs/EXAMPLES.md- Usage examples and patternsdocs/DEVELOPMENT.md- This development guideREADME.md- Main project documentation
- API Documentation: Edit JSDoc comments in
src/webfinger.ts - Examples: Edit
docs/EXAMPLES.md - Development Guide: Edit
docs/DEVELOPMENT.md - README: Edit main project info in
README.md
The project uses ESLint with TypeScript support:
bun run lintAlways lint before committing - The CI pipeline will fail if linting errors exist.
- Full TypeScript implementation with strict type checking
- All public interfaces must be properly typed and documented
- JSDoc comments required for all public methods and classes
- Use TypeScript for all source code
- Comprehensive JSDoc documentation
- Prefer
async/awaitover callbacks - Export types for better developer experience
For release instructions, see RELEASE.md - the complete guide to creating releases using GitHub Actions or manual methods.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Install dependencies:
bun install - Run tests:
bun run test
- Always use Bun - Never use npm or node commands
- Always lint and test - Run
bun run lintandbun run testbefore commits - Update documentation - Edit JSDoc comments for API changes
- Follow TypeScript conventions - Proper typing and documentation required
- Ensure all tests pass:
bun run test - Update JSDoc comments for any API changes
- Add examples to
docs/EXAMPLES.mdif needed - Create clear commit messages
- Submit pull request with description of changes
Use conventional commit format:
feat: add new WebFinger feature
fix: resolve lookup timeout issue
docs: update API documentation
refactor: improve error handling
test: add integration tests
chore: update dependencies
The library implements the WebFinger RFC 7033 protocol with these features:
- Fallback mechanisms - Multiple endpoint discovery methods
- Error handling - Comprehensive error types and status codes
- Type safety - Full TypeScript implementation
- Universal compatibility - Works in browsers and Node.js
- Single file architecture - All code in
src/webfinger.ts - UMD compatibility - Works with CommonJS, AMD, and browser globals
- Zero dependencies - Self-contained with no runtime dependencies
- TypeScript-first - Built for modern development with full type support
Build fails with TypeScript errors
- Run
bun run lintto see specific issues - Check TypeScript configuration in
tsconfig.json
Tests fail
- Ensure you're using Bun, not Node.js
- Run
bun installto update dependencies - Check test environment variables
Documentation not updating
- Run
bun run docs:generatemanually - Check JSDoc comments in TypeScript source
- Verify TypeDoc configuration in
typedoc.json
- Check existing GitHub Issues
- Review the WebFinger RFC
- Look at usage examples in
docs/EXAMPLES.md