Compare commits

...

8 Commits

Author SHA1 Message Date
Derrick Hammer 9bd04de7bb
*Update allowed ports 2023-04-17 00:23:15 -04:00
Derrick Hammer 90c6f789cc
*Update to use new multisocket proxy 2023-04-16 20:52:56 -04:00
Derrick Hammer 998d05a74c
*Create event forwards after socket is created 2023-04-15 05:45:07 -04:00
Derrick Hammer cb42eae011
*Remove unneeded method 2023-03-17 06:16:17 -04:00
Derrick Hammer 3812db6169
*Rewrite to use new IPFS proxy protocol 2023-03-17 06:13:08 -04:00
Derrick Hammer 6437e93fc4
*switch to ipfs http client. ipfs-core used by mistake 2022-08-31 20:18:37 -04:00
Derrick Hammer 9d2979067a
*Need to manage native modules
*Override __dirname
*Override @achingbrain/ssdp, default-gateway, and ipfs-utils with forks to ensure no issues
2022-08-30 02:53:25 -04:00
Derrick Hammer 175972b69d
*Initial version 2022-08-29 18:45:01 -04:00
7 changed files with 100 additions and 1 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Lume Web
Copyright (c) 2022 Hammer Technologies LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

12
build.js Normal file
View File

@ -0,0 +1,12 @@
import esbuild from 'esbuild'
esbuild.buildSync({
entryPoints: ["src/index.ts"],
outfile: "dist/ipfs.js",
format: "cjs",
bundle: true,
platform: "node",
define: {
__dirname: '"./plugins/leveldown"',
}
});

6
build.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
node build.js
mkdir dist/dist -p
rsync -avzP node_modules/leveldown/prebuilds dist/leveldown
cp node_modules/rabin-wasm/dist/rabin.wasm dist/dist/rabin.wasm

32
package.json Normal file
View File

@ -0,0 +1,32 @@
{
"name": "@lumeweb/relay-plugin-ipfs",
"type": "module",
"version": "0.1.0",
"scripts": {
"build": "node build.js"
},
"devDependencies": {
"@libp2p/interface-connection-encrypter": "^3.0.6",
"@libp2p/interface-peer-id": "^2.0.1",
"@libp2p/multistream-select": "^3.1.4",
"@lumeweb/relay-types": "git+https://git.lumeweb.com/LumeWeb/relay-types.git",
"@types/b4a": "^1.6.0",
"@types/streamx": "^2.9.1",
"esbuild": "^0.15.18",
"prettier": "^2.8.7",
"rimraf": "^3.0.2"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^11.0.4",
"@libp2p/interface-connection": "^3.1.1",
"@libp2p/peer-id": "^2.0.3",
"@lumeweb/libhyperproxy": "git+https://git.lumeweb.com/LumeWeb/libhyperproxy.git",
"@multiformats/multiaddr": "^11.6.1",
"b4a": "^1.6.3",
"compact-encoding": "^2.11.0",
"debug-stream": "^3.0.1",
"serialize-error": "^11.0.0",
"stream-to-it": "^0.2.4",
"streamx": "^2.13.2"
}
}

5
pkg/load-ipfs.json Normal file
View File

@ -0,0 +1,5 @@
{
"plugins": [
"ipfs"
]
}

30
src/index.ts Normal file
View File

@ -0,0 +1,30 @@
import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
const PROTOCOL = "lumeweb.proxy.ipfs";
interface PeerInfoResult {
publicKey: Uint8Array;
libp2pPublicKey: Uint8Array;
}
const plugin: Plugin = {
name: "ipfs",
async plugin(api: PluginAPI): Promise<void> {
const proxy = new MultiSocketProxy({
swarm: api.swarm,
protocol: PROTOCOL,
allowedPorts: [4001, 4002],
server: true,
});
api.swarm.join(api.util.crypto.createHash(PROTOCOL));
api.protocols.register(PROTOCOL, (peer: any, muxer: any) => {
proxy.handlePeer({
peer,
muxer,
});
});
},
};
export default plugin;

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "es2021",
"module": "commonjs",
"moduleResolution": "node",
"rootDir": "src",
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}