Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
ab766a5
feat(ipfs): integrate Helia as IPFS client replacing Kubo
akhileshthite May 11, 2025
930b93a
feat(ipfs): add migrateIPNSKeys script for Kubo to Helia key migration
akhileshthite May 11, 2025
1277f85
fix: use id in IPNS link instead of publishKey
akhileshthite May 12, 2025
351ff93
feat: switch to default libp2p config for Helia integration
akhileshthite May 13, 2025
ae9e6a4
feat: add WebSocket firewall rule and libp2p port
akhileshthite May 14, 2025
832c74b
feat: config addresses with separate ports for TCP and WS with firewa…
akhileshthite May 14, 2025
1d12acc
feat: add commented WebRTC Direct address config for future use
akhileshthite May 14, 2025
47a8fbf
feat: use explicit bootstrap nodes and disable mDNS in libp2p config
akhileshthite May 14, 2025
6bfe2ed
feat(libp2p): add transports and services to support full DHT mode an…
akhileshthite May 14, 2025
42376bb
chore: clean up unused dependencies
akhileshthite May 14, 2025
9aabd92
feat: enable WebRTC Direct and finalize Helia IPFS integration
akhileshthite May 14, 2025
3ce9caf
fix: avoid timeout by keeping DHT in clientMode and allowQueryWithZer…
akhileshthite May 14, 2025
aeef7ab
fix(test): ensure IPFS protocol load is awaited and assert success fo…
akhileshthite May 14, 2025
ea2e4d1
feat(libp2p): add WebRTC Direct transport for improved NAT traversal
akhileshthite May 14, 2025
e61fd8e
fix: specify dynamic port for WebRTC to avoid binding conflicts
akhileshthite May 14, 2025
d40010a
chore(ops): add migrate.mjs -> zero-dep ipns keystore copier
tripledoublev May 20, 2025
91607aa
style: fix ts-standard lint error by removing comma operator
akhileshthite May 20, 2025
d0d57b5
feat(helia): implement streaming for file sync to address memory conc…
akhileshthite May 20, 2025
ec6a09b
remove migrate-keys script and associated tests for key migration
tripledoublev May 20, 2025
8406147
export migrate function and add test for key migration
tripledoublev May 20, 2025
279c567
Merge pull request #103 from hyphacoop/feat/ipfs-streaming-file-sync
akhileshthite May 20, 2025
801d53a
test: configure AVA for ES Modules and fix test execution
akhileshthite May 20, 2025
81acafb
Merge pull request #104 from hyphacoop/update-migration-script
akhileshthite May 20, 2025
f08ac9b
fix: replace replaceAll with regex for older ES target compatibility
akhileshthite May 20, 2025
c782060
feat: add random WebRTC port selection in range 50000-60000
akhileshthite May 20, 2025
50218a1
feat: add useWebRTC flag to server configuration
akhileshthite May 21, 2025
3dd4438
Merge pull request #105 from hyphacoop/webrtc-port
akhileshthite May 21, 2025
5d65c02
rename key migration script and associated tests for clarity
tripledoublev May 21, 2025
d22d921
fix: remove IPFS provider from ExecStart in distributed.press.service.j2
tripledoublev May 21, 2025
c269df4
feat: add CustomEvent polyfill for Node.js environment
tripledoublev May 30, 2025
ed9b71b
Merge branch 'helia' into add-polyfill
tripledoublev May 30, 2025
7a317e5
feat: shim Web Crypto API to global scope for browser compatibility
tripledoublev May 30, 2025
249b589
feat: add CustomEvent polyfill and shim Web Crypto API in test
tripledoublev May 30, 2025
b36ba83
fix: ensure Web Crypto API is only shimmed if not already defined
tripledoublev Jun 2, 2025
5be8386
fix: update header text in index.html from 'Hello World!' to 'Hello H…
tripledoublev Jun 3, 2025
c8b51d4
Merge pull request #107 from hyphacoop/add-polyfill
akhileshthite Jun 3, 2025
b68f7ad
feat: disable WebRTC for testing
akhileshthite Jun 3, 2025
460fcd6
chore: remove .DS_Store
akhileshthite Jun 3, 2025
d9c2e36
fix: use unique timer labels in sync method
akhileshthite Jun 3, 2025
c41d698
chore: remove unused functions, run linter
akhileshthite Jun 3, 2025
62fc0b3
ci: remove webRTC firewall port range
akhileshthite Jun 3, 2025
5b7d6c7
fix: remove 'sites' from path to avoid nested 'sites/sites'
tripledoublev Jun 4, 2025
de2a680
add detailed logging to ipfs process
tripledoublev Jun 4, 2025
676d472
enhance tarball extraction with detailed logging
tripledoublev Jun 4, 2025
b41ccb5
fix: update directory creation to use object mapping for filenames an…
tripledoublev Jun 4, 2025
09517c7
use fresh unixfs instance per sync to avoid stale directory CID
tripledoublev Jun 4, 2025
fab8436
remove invalid fs.promises usage from unixfs wrapper
tripledoublev Jun 4, 2025
d35b481
update peer-id factory usage, CID validity checks, and file stream ha…
tripledoublev Jun 4, 2025
eccac35
replace createFromPrivKey with peerIdFromKeys
tripledoublev Jun 4, 2025
425b263
replace peerIdFromKeys import with createFromKey for peer ID generation
tripledoublev Jun 4, 2025
20b27e0
refactor: update peer ID generation to use createFromPrivKey
tripledoublev Jun 4, 2025
df3fa1f
refactor: replace createFromPrivKey with peerIdFromPrivateKey for pee…
tripledoublev Jun 4, 2025
1ad3043
refactor: update IPFS file addition to use helia.addAll and implement…
tripledoublev Jun 4, 2025
dde45fc
ensure UnixFS instance availability and update file addition to use U…
tripledoublev Jun 4, 2025
1f52303
feat: add listDirectory method to verify directory contents
akhileshthite Jun 5, 2025
a8dd003
fix: set wrapWithDirectory true in addAll to ensure directory CID
akhileshthite Jun 5, 2025
65bf50a
chore: run linter
akhileshthite Jun 5, 2025
fb5738a
chore: fix lint errors related to template expressions
akhileshthite Jun 5, 2025
481e346
feat: add WebRTC support for NAT traversal
akhileshthite Jun 5, 2025
a36c386
feat: log Helia node ID after initialization
akhileshthite Jun 5, 2025
9ea3dc2
refactor IPNS handling: match Helia’s API
tripledoublev Jun 9, 2025
48a78c1
await libp2pDefaaults
tripledoublev Jun 9, 2025
3a244dc
fix: set clientMode to false in IPFSProtocol configuration
tripledoublev Jun 9, 2025
5f21d04
fix: increase timeout for IPNS publish to 60 seconds
tripledoublev Jun 9, 2025
85423f4
feat: advertise the dirCid after pinning
akhileshthite Jun 10, 2025
e3698c4
feat: add announce for public IPs
akhileshthite Jun 10, 2025
1a2e00a
feat: add import dcutr() for better connectivity
akhileshthite Jun 10, 2025
b626de7
feat: add connectionEncrypters and streamMuxers for secure connections
akhileshthite Jun 13, 2025
00ce06b
feat: add uPnPNAT
akhileshthite Jun 13, 2025
e6355ef
fix(libp2p): preserve default services when extending libp2pOptions
akhileshthite Jun 13, 2025
e224615
Merge pull request #108 from hyphacoop/no-webrtc
tripledoublev Jun 13, 2025
2719b07
feat: convert IPNS keys from base58 to base36 format
tripledoublev Jun 13, 2025
8eb006a
fix: update peer ID conversion to include base58 multibase prefix
tripledoublev Jun 13, 2025
67b02e7
Merge pull request #109 from hyphacoop/feat/convert-ipns-keys-to-base36
akhileshthite Jun 13, 2025
4a74cff
chore: run linter
akhileshthite Jun 13, 2025
52f37aa
chore(release): bump to v3.1.0 with Helia support
akhileshthite Jun 13, 2025
0b6bab4
fix(ipns): validate and correct IPNS PeerId format during publishing
akhileshthite Jun 13, 2025
31cc14c
fix: improve resolve logic with enhanced logging
akhileshthite Jun 13, 2025
cdfc7fc
feat: add maxConnections and dialTimeout
akhileshthite Jun 13, 2025
6cc6a8e
feat: add delegatedRouting
akhileshthite Jun 13, 2025
1113b86
chore: remove clientMode and allowQueryWithZeroPeers from kadDHT to a…
akhileshthite Jun 19, 2025
8c090ff
feat: align libp2p config with js-libp2p-amino-dht-bootstrapper for a…
akhileshthite Jun 19, 2025
479543b
feat: update connectionManager to align with js-libp2p-amino-dht-boot…
akhileshthite Jun 19, 2025
937bd6f
chore: remove deprecated mplex stream muxer
akhileshthite Jun 20, 2025
f07d207
feat: enable external access for Distributed Press API by binding to …
akhileshthite Jun 20, 2025
dc2690a
chore: update distributed_press_git_branch version
akhileshthite Jun 20, 2025
5fa6aab
feat: enable external access by updating localhost bindings
akhileshthite Jun 21, 2025
491f558
fix: update distributed_press_site_storage path to remove redundant '…
tripledoublev Jun 23, 2025
7b9a684
feat: implement retry logic for DHT provide operation in IPFSProtocol
tripledoublev Jun 23, 2025
35c76e5
chore: increase test timeout from 1 minute to 3 minutes in package.json
tripledoublev Jun 23, 2025
e5f65ac
feat: add clientMode and allowQueryWithZeroPeers in kadDHT to fix tim…
akhileshthite Jun 23, 2025
8514793
feat: add removePrivateAddressesMapper and remove announce
akhileshthite Jun 23, 2025
096083b
feat: add announce with public IP and denyDialMultiaddr in connection…
akhileshthite Jun 23, 2025
bfe66db
chore: remove connectionGater from libp2p config
akhileshthite Jun 23, 2025
12006bb
chore: clear connectionManager options, comment delegatedRouting
akhileshthite Jun 23, 2025
ba4f732
feat: add reprovide in kadDHT
akhileshthite Jun 24, 2025
96dd80c
chore: increase ipns publish and provide timeout
akhileshthite Jun 24, 2025
508384e
fix: open port 7977/tcp in firewall for libp2p WebSocket connections
akhileshthite Jun 24, 2025
099971d
chore: switch libp2p ports to standard 4001 (TCP) and 4002 (WebSocket…
akhileshthite Jun 24, 2025
7bf7333
chore: update test site to get different CID
akhileshthite Jun 24, 2025
8828587
fix: IPFS content discovery by explicitly providing all CIDs to DHT i…
akhileshthite Jun 24, 2025
28dd435
feat(ipfs): ensure directory and all contents are pinned
akhileshthite Jun 24, 2025
b0936a9
chore: update helia test site for testing new CID
akhileshthite Jun 24, 2025
13bef40
feat: Update addDirectory to use globSource for recursive upload and …
akhileshthite Jun 25, 2025
a3c6d0c
chore: include optional individual CID pinning and providing
akhileshthite Jun 25, 2025
7fefec5
chore: remove optional provide comments
akhileshthite Jun 25, 2025
570cc8c
Merge pull request #115 from hyphacoop/feat/helia-globsource-recursive
akhileshthite Jun 25, 2025
934c6a0
Merge pull request #114 from hyphacoop/libp2p-amino-dht
akhileshthite Jun 25, 2025
e0fc108
chore: uncomment and use delegatedRouting
akhileshthite Jun 25, 2025
ee50a26
chore: add a TODO to run delegated routing instance
akhileshthite Jun 25, 2025
974e247
feat: add helia userAgent for api.distributed.press
akhileshthite Jul 7, 2025
996d7f3
log multiaddresses during Helia initialization
tripledoublev Jul 7, 2025
ca3e5fc
feat: start Helia node during initialization and log status
tripledoublev Jul 8, 2025
991583b
perf: extend AbortSignal timeout to 5min for IPNS publish
akhileshthite Jul 8, 2025
9f9264e
chore: disable webRTC direct for testing
akhileshthite Jul 8, 2025
cf3d9fb
perf: remove maxProvideRetries for faster DHT provide and optimize ad…
akhileshthite Jul 9, 2025
7784e2a
perf: extend AbortSignal timeout to 5min for IPNS publish
akhileshthite Jul 9, 2025
11a492c
chore: enable webRTC direct
akhileshthite Jul 9, 2025
db00b0a
chore: remove helia start
akhileshthite Jul 9, 2025
fdf555e
chore: remove delegatedRouting
akhileshthite Jul 9, 2025
320801e
chore: decrease AbortSignal.timeout
akhileshthite Jul 9, 2025
e46e4d0
remove multiaddr logging during IPFS initialization
tripledoublev Jul 9, 2025
5be4189
perf: add maxProvideRetries
akhileshthite Jul 9, 2025
451c534
perf: increase the default reprovide concurrency
akhileshthite Jul 22, 2025
2772b35
perf: announce webRTCDirect and add circuitRelayTransport
akhileshthite Jul 22, 2025
9f1c6af
perf: disable webRTC globally
akhileshthite Jul 22, 2025
3125928
update cron job to restart api.distributed.press service daily
tripledoublev Jul 24, 2025
22cc695
update package state and cache settings in distributed_press role
tripledoublev Jul 24, 2025
ea79f99
fix cache for failing install
tripledoublev Jul 24, 2025
f965df3
fix: update installation command for wget2 to ensure package list is …
tripledoublev Jul 24, 2025
e19496b
perf(ipfs): enable automatic CID reproviding in kadDHT and delegatedR…
akhileshthite Jul 27, 2025
582c2b7
fix(ipfs): migrate to level-based datastores to address CID discovera…
akhileshthite Aug 6, 2025
de9e4f5
perf(ipfs): optimize network settings and enable WebRTC
akhileshthite Aug 6, 2025
b8fa231
chore: upgrade @libp2p/kad-dht to latest for reprovide bug fix
akhileshthite Aug 20, 2025
da16158
optimize sync performance for faster uploads
tripledoublev Sep 15, 2025
1537fc2
fix typescript error in background DHT provide
tripledoublev Sep 15, 2025
22fda86
fix esm configuration for ts-node
tripledoublev Sep 15, 2025
62b6c23
Merge pull request #118 from hyphacoop/helia-optimized
tripledoublev Nov 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Install wget2 for cloning
run: sudo apt-get install -y wget2
run: sudo apt-get update && sudo apt-get install -y wget2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
4 changes: 0 additions & 4 deletions @types/go-ipfs.d.ts

This file was deleted.

8 changes: 3 additions & 5 deletions ansible/roles/distributed_press/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ distributed_press_user: "press"
distributed_press_home: "/home/{{distributed_press_user}}"
distributed_press_service_name: "distributed.press"
distributed_press_data: "{{distributed_press_home}}/.local/share/distributed-press-nodejs"
distributed_press_site_storage: "{{distributed_press_data}}/sites/sites"
distributed_press_site_storage: "{{distributed_press_data}}/sites"

# 3932 is DWEB on a phone number pad
distributed_press_port: "3932"
distributed_press_host: "localhost"

distributed_press_ipfs_provider: "builtin"
distributed_press_host: "0.0.0.0"

distributed_press_git_repo: "https://github.com/hyphacoop/api.distributed.press.git"
distributed_press_git_branch: "v3.0.0"
distributed_press_git_branch: "v3.1.0"
distributed_press_source: "{{distributed_press_home}}/api.distributed.press"

distributed_press_domain: "example.com"
Expand Down
26 changes: 16 additions & 10 deletions ansible/roles/distributed_press/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
pkg:
- git
- ufw
state: latest
update_cache: true
state: present
update_cache: yes
cache_valid_time: 3600

- name: Add distributed.press systemd service
template:
Expand Down Expand Up @@ -66,11 +67,14 @@
- name: "Enable DNS traffic through firewall"
shell: "ufw allow in 53/udp"

- name: "Enable libp2p udp traffic through firewall"
shell: "ufw allow in 7976/udp"

- name: "Enable libp2p tcp traffic through firewall"
shell: "ufw allow in 7976/tcp"
shell: "ufw allow in 4001/tcp"

- name: "Enable libp2p WebSocket TCP traffic through firewall"
shell: "ufw allow in 4002/tcp"

- name: "Enable libp2p WebRTC UDP traffic through firewall (50000-60000)"
shell: "ufw allow 50000:60000/udp"

- name: "Check if JWT keys got generated already"
stat:
Expand Down Expand Up @@ -153,12 +157,14 @@
enabled: true
name: "{{social_inbox_service_name}}"

- name: "Add cron job to restart api.distributed.press service every few days"
- name: "Add cron job to restart api.distributed.press service every day"
cron:
name: "Restart api.distributed.press service"
hour: "0"
minute: "0"
weekday: "6" # Saturday
day: "*"
month: "*"
weekday: "*"
job: "/bin/systemctl restart {{ distributed_press_service_name }}"
become: yes
tags:
Expand All @@ -170,8 +176,8 @@
- certbot
- nginx
- python3-certbot-nginx
state: latest
update_cache: true
state: present
update_cache: no

- name: "Enable NGINX firewall"
shell: "ufw allow 'Nginx Full'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network-online.target
# Environment="DEBUG=*"
WorkingDirectory={{distributed_press_source}}
User={{distributed_press_user}}
ExecStart=npx ts-node-esm index.ts --port {{distributed_press_port}} --host {{distributed_press_host}} --domain {{distributed_press_domain}} --ipfs-provider {{distributed_press_ipfs_provider}}
ExecStart=npx ts-node-esm index.ts --port {{distributed_press_port}} --host {{distributed_press_host}} --domain {{distributed_press_domain}}
Restart=always
RestartSec=3
LimitNOFILE=4096
Expand Down
3 changes: 2 additions & 1 deletion api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type APIConfig = Partial<{
useMemoryBackedDB: boolean
useSigIntHandler: boolean
useWebringDirectoryListing: boolean
useWebRTC: boolean
}> & ServerI

async function apiBuilder (cfg: APIConfig): Promise<FastifyTypebox> {
Expand All @@ -55,7 +56,7 @@ async function apiBuilder (cfg: APIConfig): Promise<FastifyTypebox> {
const protocols = new ConcreteProtocolManager({
ipfs: {
path: path.join(protocolStoragePath, 'ipfs'),
provider: cfg.ipfsProvider
useWebRTC: cfg.useWebRTC ?? true
},
hyper: {
path: path.join(protocolStoragePath, 'hyper')
Expand Down
5 changes: 1 addition & 4 deletions config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AdminStore } from './admin.js'
import { PublisherStore } from './publisher.js'
import { RevocationStore } from './revocations.js'
import { SiteConfigStore } from './sites.js'
import path from 'path'
import { ProtocolManager } from '../protocols/index.js'

export interface StoreI {
Expand All @@ -28,9 +27,7 @@ export default class Store implements StoreI {
this.db = db

const basePath = cfg.storage
const siteStoragePath = path.join(basePath, 'sites')

this.fs = new SiteFileSystem(siteStoragePath)
this.fs = new SiteFileSystem(basePath)
this.admin = new AdminStore(this.db.sublevel('admin', { valueEncoding: 'json' }))
this.publisher = new PublisherStore(this.db.sublevel('publisher', { valueEncoding: 'json' }))
this.sites = new SiteConfigStore(this.db.sublevel('sites', { valueEncoding: 'json' }), protocols)
Expand Down
2 changes: 1 addition & 1 deletion fixtures/site/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<title>Hello Distributed Press!</title>
<h1>Hello World!</h1>
<h1>Hello Helia!!</h1>
4 changes: 1 addition & 3 deletions fixtures/spawnServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import fs from 'fs'
import { generateKeyPair } from '../authorization/jwt.js'
import apiBuilder, { FastifyTypebox } from '../api/index.js'
import { nanoid } from 'nanoid'
import { BUILTIN } from '../protocols/ipfs.js'
import getPort from 'get-port'

const paths = envPaths('distributed-press')
Expand All @@ -22,7 +21,6 @@ export async function spawnTestServer (): Promise<FastifyTypebox> {
dnsport: await getPort(),
host: 'localhost',
domain: 'example.com',
storage: storagePath,
ipfsProvider: BUILTIN
storage: storagePath
})
}
34 changes: 25 additions & 9 deletions fs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,30 @@ export class SiteFileSystem {
/// the target directory
async extract (tarballPath: string, siteId: string): Promise<string> {
const sitePath = this.getPath(siteId)
await pipeline(
fs.createReadStream(tarballPath),
gunzip(),
tar.extract(sitePath, {
readable: true,
writable: true
})
)
return sitePath
console.log(`[fs] Extracting tarball from ${tarballPath} to ${sitePath}`)

try {
await pipeline(
fs.createReadStream(tarballPath),
gunzip(),
tar.extract(sitePath, {
readable: true,
writable: true,
map: (header) => {
console.log(`[fs] Extracting file: ${header.name}`)
return header
}
})
)

// Verify extraction by listing directory contents
const files = await fs.promises.readdir(sitePath)
console.log(`[fs] Extraction complete. Files in ${sitePath}:`, files)

return sitePath
} catch (err) {
console.error(`[fs] Error extracting tarball: ${err instanceof Error ? err.message : String(err)}`)
throw err
}
}
}
27 changes: 22 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
// Polyfill CustomEvent for Node.js environment
// Shim Web Crypto API to global scope for browser-compatible libraries
import { webcrypto } from 'node:crypto'

import apiBuilder from './api/index.js'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import envPaths from 'env-paths'
import { IPFSProvider, BUILTIN } from './protocols/ipfs.js'

if (typeof CustomEvent === 'undefined') {
class CustomEvent<T = any> extends Event {
detail: T
constructor (type: string, options?: CustomEventInit<T>) {
super(type, options)
this.detail = options?.detail as T
}
}
(globalThis as any).CustomEvent = CustomEvent
}
if (typeof (globalThis as any).crypto === 'undefined') {
(globalThis as any).crypto = webcrypto
}
const paths = envPaths('distributed-press')

const argv = yargs(hideBin(process.argv)).options({
Expand All @@ -11,7 +28,7 @@ const argv = yargs(hideBin(process.argv)).options({
host: { type: 'string' },
domain: { type: 'string' },
data: { type: 'string' },
ipfsProvider: { type: 'string' }
useWebRTC: { type: 'boolean', default: undefined }
}).parseSync()

export interface ServerI {
Expand All @@ -20,16 +37,16 @@ export interface ServerI {
host: string
domain: string
storage: string
ipfsProvider: IPFSProvider
useWebRTC?: boolean
}

const cfg: ServerI = {
port: Number(argv.port ?? process.env.PORT ?? '8080'),
dnsport: Number(argv.dnsport ?? process.env.DNSPORT ?? '53'),
host: argv.host ?? process.env.HOST ?? 'localhost',
host: argv.host ?? process.env.HOST ?? '0.0.0.0',
domain: argv.domain ?? process.env.DOMAIN ?? 'localhost',
storage: argv.data ?? paths.data,
ipfsProvider: (argv.ipfsProvider as IPFSProvider) ?? BUILTIN
useWebRTC: argv.useWebRTC ?? (process.env.USE_WEBRTC?.toLowerCase() === 'false' ? false : process.env.CI !== 'true')
}

const server = await apiBuilder({
Expand Down
Loading