Status: 0.1.0-RC1 — run npm run ci before release tags (tests + script build).
| Doc | Purpose |
|---|---|
| docs/PRODUCTION.md | Deploy, TLS, WebSocket, versioning |
| docs/MARKETING_OVERVIEW.md | Positioning & ecosystem copy |
| docs/RELEASE_CHECKLIST.md | Tag & publish steps |
| CHANGELOG.md | Release notes |
Peering / WebRTC: Browser signaling is native WebRTC (Hub Bridge + JSON-RPC), not Fabric TCP P2P_SESSION_OFFER/OPEN. Phase alignment with the CLI mental model lives in @fabric/core: docs/SESSION_AND_WEBRTC.md (use the path in your pinned core checkout).
Robust library for implementing Fabric-enabled Web Applications.
Fabric is an attempt at replicating the World Wide Web ("the WWW") as a peer-to-peer network, using payment relationships to exchange documents and scale the network. @fabric/http provides a framework for hosting Fabric-enabled applications over HTTP, allowing them to be used as "edge servers" for legacy web users.
Building applications with @fabric/http is easy.
mkdir some-project && cd some-project
npm init # Initialize the project
npm i --save @fabric/http # Install the @fabric/http dependencyFrom a clone of this repository:
npm ci
npm run ci # tests + build:scripts — use before tags / CIThe fabric-http binary serves a directory with Express static middleware (correct Content-Type, caching, ETag, dotfile hiding) plus Fabric services (WebSocket /, JSON-RPC when enabled, peering/WebRTC signaling via the Hub rather than legacy PeerJS, etc.). Treat it like http-server for the filesystem, with extra endpoints.
npx fabric-http ./dist -p 8080 -a 0.0.0.0
# cache static assets for one hour (seconds, like http-server -c)
npx fabric-http ./assets -c 3600
# client-side routing: serve index.html when no matching file exists
npx fabric-http ./build --spaProgrammatic options on new HTTPServer({ ... }) include assets (or path alias for the static root), static: { cacheSeconds, ... }, spaFallback, jsonRpc: { enabled, paths }, cors, and compression. HTTP JSON-RPC (POST /rpc) uses the same _handleCall surface as WebSocket JSONCall when jsonRpc.enabled is true (e.g. hub.fabric.pub).
@fabric/http includes a deterministic, Gravatar-like Avatar class with a Fabric-themed palette and an academic visual-hash approach inspired by "drunken bishop" / marching-bishop algorithms:
const Avatar = require('@fabric/http/types/avatar');
const avatar = new Avatar('alice@example.edu', { size: 96 });
const svg = avatar.toSVG();
const dataURI = avatar.toDataURI();
const imgHTML = avatar.render(); // <img class="fabric-avatar" ...>
const ascii = avatar.toASCII(); // terminal-friendly visual hashThe same input always yields the same SVG; different identities produce different board walks.
For browser custom-elements, @fabric/http also exposes FabricAvatar on types/web:
const { FabricAvatar } = require('@fabric/http');
customElements.define('fabric-avatar', FabricAvatar);tests/standards.http.js covers RFC 6902 JSON Patch (fast-json-patch), JSON Schema checks for JSON-RPC 2.0 bodies (tests/schemas/jsonrpc.js, AJV as a devDependency), HTML5-shaped responses with jsdom (tests/helpers/htmlCompliance.js), Accept / formatResponse negotiation, static files, POST /rpc, and OPTIONS /. Run: npx mocha tests/standards.http.js --exit.
When @fabric/core is cloned alongside this repo, install it so Message types (e.g. P2P_MESSAGE_RECEIPT) and HTTP behavior stay aligned:
npm install ../fabric --no-saveCreate an application by creating a new file (here we've used scripts/node.js), containing the following:
'use strict';
// Dependencies
const SPA = require('@fabric/http/types/spa');
// Main Process
async function main () {
const spa = new SPA({
name: 'Example Application',
synopsis: 'Simple demonstration of a single-page application.',
resources: {
'Todo': {
description: 'A to-do list item.'
}
}
});
// Start the Process
await spa.start();
// Return reference
return { id: spa.id };
}
main().catch((exception) => {
console.log('[FABRIC-HTTP:EXAMPLE] Main Process Exception:', exception);
}).then((output) => {
console.log('[FABRIC-HTTP:EXAMPLE] Main Process Output:', output);
});Run node scripts/node.js to start the app, or webpack scripts/app.js -o assets/app.min.js to
build a browser version.