Compare commits

..

37 Commits

Author SHA1 Message Date
semantic-release-bot 8a937fc2b9 chore(release): 0.1.0-develop.11 [skip ci]
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-09-02)

### Bug Fixes

* switch mkeyEd25519 to CID_HASH_TYPES ([8780042](87800422e3))
2023-09-02 18:55:43 +00:00
Derrick Hammer 87800422e3
fix: switch mkeyEd25519 to CID_HASH_TYPES 2023-09-02 14:54:56 -04:00
Derrick Hammer bb40e51eee
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 14:54:10 -04:00
Derrick Hammer 5546934ca2
dep: update libs5-transport-hyper 2023-09-02 14:54:05 -04:00
semantic-release-bot 9acb0e1bac chore(release): 0.1.0-develop.10 [skip ci]
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-09-01)
2023-09-01 14:17:47 +00:00
Derrick Hammer bfead1f76f
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 10:16:46 -04:00
Derrick Hammer 523b371c74
dep: update libs5-transport-hyper 2023-09-01 10:16:41 -04:00
semantic-release-bot c27bf22af9 chore(release): 0.1.0-develop.9 [skip ci]
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-09-01)
2023-09-01 12:35:34 +00:00
Derrick Hammer 6cb2d71b99
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 08:34:37 -04:00
Derrick Hammer 50c9daf7dd
dep: update libs5-transport-hyper 2023-09-01 08:34:33 -04:00
semantic-release-bot 085576a2c6 chore(release): 0.1.0-develop.8 [skip ci]
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-01)
2023-09-01 11:41:58 +00:00
Derrick Hammer 54294d2f90
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 07:41:09 -04:00
Derrick Hammer d57742ce94
dep: update libs5-transport-hyper 2023-09-01 07:41:05 -04:00
semantic-release-bot 93b2d78e19 chore(release): 0.1.0-develop.7 [skip ci]
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-09-01)
2023-09-01 10:50:46 +00:00
Derrick Hammer e4d6aa8ded
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 06:50:03 -04:00
Derrick Hammer 6ac0087007
dep: update libs5-transport-hyper 2023-09-01 06:49:57 -04:00
semantic-release-bot 0a88d8c368 chore(release): 0.1.0-develop.6 [skip ci]
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-09-01)

### Bug Fixes

* bad argument nesting ([61f333f](61f333feaa))
* use privateKey not publicKeyRaw ([78bee5c](78bee5c47b))
2023-09-01 08:15:15 +00:00
Derrick Hammer c27634eb7e
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 04:14:28 -04:00
Derrick Hammer 61f333feaa
fix: bad argument nesting 2023-09-01 04:10:37 -04:00
Derrick Hammer 78bee5c47b
fix: use privateKey not publicKeyRaw 2023-09-01 04:10:02 -04:00
semantic-release-bot d4761a26d6 chore(release): 0.1.0-develop.5 [skip ci]
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-09-01)

### Bug Fixes

* need to ensure we prefix the node id with the key type identifier ([a19c515](a19c515dda))
2023-09-01 07:23:43 +00:00
Derrick Hammer 2f40a56c34
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 03:22:51 -04:00
Derrick Hammer a19c515dda
fix: need to ensure we prefix the node id with the key type identifier 2023-09-01 03:22:46 -04:00
semantic-release-bot f3be20ca3f chore(release): 0.1.0-develop.4 [skip ci]
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-08-31)
2023-08-31 22:55:54 +00:00
Derrick Hammer 320dec6e26
Merge remote-tracking branch 'origin/develop' into develop 2023-08-31 18:55:13 -04:00
Derrick Hammer e7935729f3
refactor: switch to @lumeweb/libs5-transport-hyper 2023-08-31 18:54:47 -04:00
semantic-release-bot 2677ad66f7 chore(release): 0.1.0-develop.3 [skip ci]
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-08-31)

### Bug Fixes

* path needs to be plugin ([83cc7f9](83cc7f9c10))
2023-08-31 16:33:56 +00:00
Derrick Hammer 9fcfc686cf
Merge remote-tracking branch 'origin/develop' into develop 2023-08-31 12:33:14 -04:00
Derrick Hammer 83cc7f9c10
fix: path needs to be plugin 2023-08-31 12:33:04 -04:00
semantic-release-bot 750a3bafd4 chore(release): 0.1.0-develop.2 [skip ci]
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-08-31)

### Bug Fixes

* ensure db path exists, create if not ([632eb13](632eb1351c))
* set default db path ([51618df](51618dfaf3))
2023-08-31 16:15:37 +00:00
Derrick Hammer 49eb1bab8a
Merge remote-tracking branch 'origin/develop' into develop 2023-08-31 12:14:50 -04:00
Derrick Hammer 51618dfaf3
fix: set default db path 2023-08-31 12:14:42 -04:00
Derrick Hammer 632eb1351c
fix: ensure db path exists, create if not 2023-08-31 12:14:28 -04:00
semantic-release-bot 1ab97adce3 chore(release): 0.1.0-develop.1 [skip ci]
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.0.1...v0.1.0-develop.1) (2023-08-31)

### Features

* Initial version ([4444afa](4444afa5fa))
2023-08-31 16:05:43 +00:00
Derrick Hammer 908aacdae6
ci: override moduleResolution 2023-08-31 12:05:01 -04:00
Derrick Hammer 7ff8957f03
ci: setup 2023-08-31 12:02:15 -04:00
Derrick Hammer 4444afa5fa
feat: Initial version 2023-08-31 11:57:11 -04:00
9 changed files with 19857 additions and 0 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

12
.presetterrc.json Normal file
View File

@ -0,0 +1,12 @@
{
"preset": [
"@lumeweb/presetter-relay-plugin-preset"
],
"config": {
"tsconfig": {
"compilerOptions": {
"moduleResolution": "node"
}
}
}
}

53
CHANGELOG.md Normal file
View File

@ -0,0 +1,53 @@
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-09-02)
### Bug Fixes
* switch mkeyEd25519 to CID_HASH_TYPES ([8780042](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/87800422e3c419f81b0e623f1895648f01ab86bf))
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-09-01)
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-09-01)
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-01)
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-09-01)
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-09-01)
### Bug Fixes
* bad argument nesting ([61f333f](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/61f333feaafa37fe67adc7a7238b3a1b09da322e))
* use privateKey not publicKeyRaw ([78bee5c](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/78bee5c47ba87118cca89f46acbea479ba028df0))
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-09-01)
### Bug Fixes
* need to ensure we prefix the node id with the key type identifier ([a19c515](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/a19c515dda5f533901d35a3c6ffdd39a82a1fa30))
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-08-31)
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-08-31)
### Bug Fixes
* path needs to be plugin ([83cc7f9](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/83cc7f9c1008e00b6cd3b461672444507ffd578e))
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-08-31)
### Bug Fixes
* ensure db path exists, create if not ([632eb13](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/632eb1351c92825c10681487efc7cfa3f5cebac6))
* set default db path ([51618df](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/51618dfaf38c4dc9ad70fc6a76ca11ef37fad0f5))
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/compare/v0.0.1...v0.1.0-develop.1) (2023-08-31)
### Features
* Initial version ([4444afa](https://git.lumeweb.com/LumeWeb/relay-plugin-s5/commit/4444afa5fa9ce1f873917324fce8be4393d0dadc))

19666
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

26
package.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "@lumeweb/relay-plugin-s5",
"version": "0.1.0-develop.11",
"type": "module",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/relay-plugin-s5.git"
},
"devDependencies": {
"@lumeweb/presetter-relay-plugin-preset": "^0.1.0-develop.1",
"ed25519-keygen": "^0.4.8",
"presetter": "^4.1.2"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/interface-relay": "^0.0.2-develop.3",
"@lumeweb/libs5-transport-hyper": "^0.1.0-develop.18",
"@types/streamx": "^2.9.1",
"streamx": "^2.15.1"
}
}

7
pkg/load-s5.json Normal file
View File

@ -0,0 +1,7 @@
{
"core": {
"plugins": [
"s5"
]
}
}

15
pkg/s5.json Normal file
View File

@ -0,0 +1,15 @@
{
"plugin": {
"s5": {
"db": "/etc/lumeweb/relay/plugins/s5/db",
"p2p": {
"peers": {
"initial": [
"wss://z2DWuWNZcdSyZLpXFK2uCU3haaWMXrDAgxzv17sDEMHstZb@s5.garden/s5/p2p",
"wss://z2DWuPbL5pweybXnEB618pMnV58ECj2VPDNfVGm3tFqBvjF@s5.ninja/s5/p2p"
]
}
}
}
}
}

1
src/constants.ts Normal file
View File

@ -0,0 +1 @@
export const PROTOCOL = "lumeweb.service.s5";

64
src/index.ts Normal file
View File

@ -0,0 +1,64 @@
import type { PluginAPI } from "@lumeweb/interface-relay";
import {
S5NodeConfig,
createKeyPair,
createNode,
NodeId,
CID_HASH_TYPES,
} from "@lumeweb/libs5";
import HyperTransportPeer from "@lumeweb/libs5-transport-hyper";
import { concatBytes } from "@noble/curves/abstract/utils";
import { Level } from "level";
import { PROTOCOL } from "./constants.js";
import * as fs from "fs/promises";
const plugin = {
name: "s5",
async plugin(api: PluginAPI) {
const dbPath = api.pluginConfig.str("db") as string;
try {
await fs.access(dbPath);
} catch {
await fs.mkdir(dbPath, { recursive: true });
}
const db = new Level<string, Uint8Array>(dbPath);
await db.open();
let config = {
keyPair: createKeyPair(api.identity.privateKey),
db,
p2p: {
peers: {
initial: api.pluginConfig.array("p2p.peers.initial") ?? [],
},
},
} as S5NodeConfig;
const node = createNode(config);
await node.start();
api.swarm.join(api.util.crypto.createHash(PROTOCOL));
api.protocols.register(PROTOCOL, async (peer: any, muxer: any) => {
const s5peer = new HyperTransportPeer({
muxer,
peer,
protocol: PROTOCOL,
});
s5peer.id = new NodeId(
concatBytes(
Uint8Array.from([CID_HASH_TYPES.ED25519]),
peer.remotePublicKey,
),
);
await s5peer.init();
node.services.p2p.onNewPeer(s5peer, true);
});
},
};
export default plugin;