Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 9bd04de7bb | |
Derrick Hammer | 90c6f789cc | |
Derrick Hammer | 998d05a74c | |
Derrick Hammer | cb42eae011 | |
Derrick Hammer | 3812db6169 | |
Derrick Hammer | 6437e93fc4 | |
Derrick Hammer | 9d2979067a | |
Derrick Hammer | 175972b69d |
2
LICENSE
2
LICENSE
|
@ -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
|
||||
|
|
|
@ -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"',
|
||||
}
|
||||
});
|
|
@ -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
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"plugins": [
|
||||
"ipfs"
|
||||
]
|
||||
}
|
|
@ -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;
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue