Skip to content

feat: upgrade protocol handlers to use new protocol.handle() API #124

@akhileshthite

Description

@akhileshthite

Our current protocol handlers use the deprecated protocol.registerStreamProtocol() API. We need to migrate to the modern protocol.handle() API which uses fetch-style request/response patterns.

### Current approach (deprecated):

protocol.registerStreamProtocol('ipfs', (request, callback) => {
  // Stream-based handler
  callback({ statusCode: 200, data: stream });
});

New approach (protocol.handle):

protocol.handle('ipfs', async (request) => {
  // Fetch-style handler - return Response object
  return new Response(body, {
    status: 200,
    headers: { 'content-type': 'text/html' }
  });
});

Main registration:

  • src/main.js - Change protocol.registerStreamProtocol() to protocol.handle()
    Protocol handlers (all need fetch-style conversion):
  • src/protocols/ipfs-handler.js
  • src/protocols/hyper-handler.js
  • src/protocols/web3-handler.js
  • src/protocols/file-handler.js
  • src/protocols/hs-handler.js
  • src/protocols/bittorrent-handler.js
  • src/protocols/peersky-protocol.js
  • src/protocols/theme-handler.js

After migration, test all protocols:

Accessing (read operations):

  • ipfs:// - Load CID content
  • hyper:// - Load Hypercore data
  • file:// - Directory listings and file access
  • hs:// - peersky://p2p/p2pmd app
  • bittorrent:// / bt:// - Torrent content
  • web3:// - Web3 resources
  • peersky:// - Internal browser pages

Publishing (write operations):

  • IPFS upload via peersky://upload or other p2p apps.
  • Hyper publishing same as above

Note: Visit these after this is addressed #15 #16

Metadata

Metadata

Assignees

Labels

electronRelated to electron.jsenhancementNew feature or requestpriority: highFor important issues that affect many users or major functionality of the projectprotocolNew protocol to support ://

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions