Compare commits

...

20 Commits

Author SHA1 Message Date
semantic-release-bot d86e749e72 chore(release): 0.0.2-develop.7 [skip ci]
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-10-13)
2023-10-13 07:00:50 +00:00
Derrick Hammer 14c5892ab5
Merge remote-tracking branch 'origin/develop' into develop 2023-10-13 02:59:54 -04:00
Derrick Hammer 26576d809e
refactor: cheat temp and hard code the relay server 2023-10-13 02:59:49 -04:00
semantic-release-bot 85d81b4d6f chore(release): 0.0.2-develop.6 [skip ci]
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-07-12)

### Bug Fixes

* increase timeout to 3 seconds ([780573a](780573aa7d))
2023-07-12 11:26:43 +00:00
Derrick Hammer e44b63b63e
Merge remote-tracking branch 'origin/develop' into develop 2023-07-12 07:25:57 -04:00
Derrick Hammer 780573aa7d
fix: increase timeout to 3 seconds 2023-07-12 07:25:53 -04:00
semantic-release-bot d9ef28532f chore(release): 0.0.2-develop.5 [skip ci]
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-07-12)

### Bug Fixes

* add reject reason for logging ([00560a6](00560a64a7))
2023-07-12 11:22:28 +00:00
Derrick Hammer 1ddcf5be81
Merge remote-tracking branch 'origin/develop' into develop 2023-07-12 07:21:29 -04:00
Derrick Hammer 00560a64a7
fix: add reject reason for logging 2023-07-12 07:21:08 -04:00
semantic-release-bot de08d8ab3a chore(release): 0.0.2-develop.4 [skip ci]
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-07-12)

### Bug Fixes

* add 1 second timeout to auto-reject and close the connection ([ac4aace](ac4aaceb73))
2023-07-12 06:51:54 +00:00
Derrick Hammer 71267ae892
Merge remote-tracking branch 'origin/develop' into develop 2023-07-12 02:50:54 -04:00
Derrick Hammer ac4aaceb73
fix: add 1 second timeout to auto-reject and close the connection 2023-07-12 02:50:44 -04:00
semantic-release-bot 33da202f99 chore(release): 0.0.2-develop.3 [skip ci]
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-03)

### Bug Fixes

* use utf8ToBytes ([a6ec4d6](a6ec4d6bed))
2023-07-03 21:33:51 +00:00
Derrick Hammer 17b9af7e71
Merge remote-tracking branch 'origin/develop' into develop 2023-07-03 17:32:46 -04:00
Derrick Hammer a6ec4d6bed
fix: use utf8ToBytes 2023-07-03 17:32:40 -04:00
semantic-release-bot 2ec10660e5 chore(release): 0.0.2-develop.2 [skip ci]
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-03)
2023-07-03 21:20:31 +00:00
Derrick Hammer a32dbb117a
refactor: switch to use noble binary utils 2023-07-03 14:22:40 -04:00
semantic-release-bot 1f75489d0d chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.1...v0.0.2-develop.1) (2023-07-01)
2023-07-01 22:13:27 +00:00
Derrick Hammer 6b6278813a
ci: official doesn't apply 2023-07-01 18:12:12 -04:00
Derrick Hammer 8bd5ae948a
refactor: update to use new ci and libraries 2023-07-01 18:06:51 -04:00
10 changed files with 19282 additions and 221 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

5
.presetterrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

33
CHANGELOG.md Normal file
View File

@ -0,0 +1,33 @@
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-10-13)
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-07-12)
### Bug Fixes
* increase timeout to 3 seconds ([780573a](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/commit/780573aa7d025590dfc8dbedf9aa380d4888bc8a))
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-07-12)
### Bug Fixes
* add reject reason for logging ([00560a6](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/commit/00560a64a7fc6ee280fc8496c96a74a6d272a730))
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-07-12)
### Bug Fixes
* add 1 second timeout to auto-reject and close the connection ([ac4aace](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/commit/ac4aaceb73f434a5b832c597973c9cba1c4cc1cd))
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-03)
### Bug Fixes
* use utf8ToBytes ([a6ec4d6](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/commit/a6ec4d6bedb660c80b2cfd13cddf71e913f4347e))
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-03)
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/peer-discovery-irc/compare/v0.0.1...v0.0.2-develop.1) (2023-07-01)

6
dist/index.d.ts vendored
View File

@ -1,6 +0,0 @@
/// <reference types="node" resolution-mode="require"/>
import type { Peer } from "@lumeweb/peer-discovery";
declare const _default: (pubkey: Buffer, options?: {
host: string;
}) => Promise<boolean | Peer>;
export default _default;

46
dist/index.js vendored
View File

@ -1,46 +0,0 @@
import { IrcClient } from "@ctrl/irc";
import jsonStringify from "json-stringify-deterministic";
import b4a from "b4a";
import * as ed from "@noble/ed25519";
import { ripemd160 } from "@noble/hashes/ripemd160";
import { sha256 } from "@noble/hashes/sha256";
import { bytesToHex } from "@noble/hashes/utils";
const hash160 = (data) => ripemd160(sha256(data));
export default async (pubkey, options = { host: "irc.liberta.casa" }) => {
let ircPubKey = await ed.getPublicKey(ed.utils.randomPrivateKey());
let client = new IrcClient(undefined, bytesToHex(hash160(ircPubKey)).substring(0, 15), {
host: options.host,
port: 6697,
secure: true,
channels: ["#lumeweb"],
realName: "lumeweb-client",
});
client.connect();
await new Promise((resolve) => {
client.once("join", resolve);
});
client.say("#lumeweb", b4a.toBuffer(pubkey).toString("hex"));
return new Promise((resolve, reject) => {
client.on("pm", async (from, text) => {
let json;
try {
json = JSON.parse(text);
}
catch {
return;
}
const verifyData = {
host: json.host,
port: json.port,
timestamp: json.timestamp,
};
const verifyPayload = jsonStringify(verifyData);
if (!(await ed.verify(b4a.from(json.signature, "hex"), b4a.from(verifyPayload), pubkey))) {
return;
}
client.end();
resolve({ host: json.host, port: json.port });
});
});
};
//# sourceMappingURL=index.js.map

19183
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,33 @@
{ {
"name": "@lumeweb/peer-discovery-irc", "name": "@lumeweb/peer-discovery-irc",
"version": "0.1.0", "version": "0.0.2-develop.7",
"main": "dist/index.js", "main": "lib/index.js",
"type": "module", "type": "module",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/peer-discovery-irc.git"
},
"devDependencies": { "devDependencies": {
"@types/b4a": "^1.6.0", "@lumeweb/node-library-preset": "^0.2.7",
"@types/node": "^18.11.17", "presetter": "*"
"prettier": "^2.8.3", },
"typescript": "^4.9.4" "readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
}, },
"dependencies": { "dependencies": {
"@ctrl/irc": "^2.1.0", "@ctrl/irc": "^2.1.1",
"@lumeweb/peer-discovery": "git+https://git.lumeweb.com/LumeWeb/peer-discovery.git", "@lumeweb/libpeerdiscovery": "^0.1.0-develop.1",
"@noble/ed25519": "^1.7.1", "@noble/curves": "^1.1.0",
"@noble/hashes": "^1.1.5", "@noble/hashes": "^1.3.1",
"b4a": "^1.6.1",
"json-stringify-deterministic": "^1.0.8" "json-stringify-deterministic": "^1.0.8"
},
"files": [
"lib/**"
],
"publishConfig": {
"access": "public"
} }
} }

View File

@ -1,128 +0,0 @@
lockfileVersion: 5.4
specifiers:
'@ctrl/irc': ^2.1.0
'@lumeweb/peer-discovery': git+https://git.lumeweb.com/LumeWeb/peer-discovery.git
'@noble/ed25519': ^1.7.1
'@noble/hashes': ^1.1.5
'@types/b4a': ^1.6.0
'@types/node': ^18.11.17
b4a: ^1.6.1
json-stringify-deterministic: ^1.0.8
prettier: ^2.8.3
typescript: ^4.9.4
dependencies:
'@ctrl/irc': 2.1.0
'@lumeweb/peer-discovery': git.lumeweb.com/LumeWeb/peer-discovery/abdb430c273301f7652feb8f9026c89a78f58d7a
'@noble/ed25519': 1.7.1
'@noble/hashes': 1.1.5
b4a: 1.6.1
json-stringify-deterministic: 1.0.8
devDependencies:
'@types/b4a': 1.6.0
'@types/node': 18.11.18
prettier: 2.8.3
typescript: 4.9.4
packages:
/@ctrl/irc/2.1.0:
resolution: {integrity: sha512-cVCXsKZVZ0seciCdTmwF9PUt+t/QCjJl6HYUPhkMrOTh6voQ9lqipUxF0/fLksBl2hrRiITgBXvTjpNYLdkbJQ==}
engines: {node: '>=14.16'}
dependencies:
chardet: 1.5.1
debug: 4.3.4
iconv-lite: 0.6.3
lodash.defaultsdeep: 4.6.1
tiny-typed-emitter: 2.1.0
transitivePeerDependencies:
- supports-color
dev: false
/@noble/ed25519/1.7.1:
resolution: {integrity: sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==}
dev: false
/@noble/hashes/1.1.5:
resolution: {integrity: sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==}
dev: false
/@types/b4a/1.6.0:
resolution: {integrity: sha512-rYU2r5nSUPyKyufWijxgTjsFp2kLCwydj2TmKU4StJeGPHS/Fs5KHgP89DNF0jddyeAbN5mdjNDqIrjIHca60g==}
dependencies:
'@types/node': 18.11.18
dev: true
/@types/node/18.11.18:
resolution: {integrity: sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==}
dev: true
/b4a/1.6.1:
resolution: {integrity: sha512-AsKjNhz72yxteo/0EtQEiwkMUgk/tGmycXlbG4g3Ard2/ULtNLUykGOkeK0egmN27h0xMAhb76jYccW+XTBExA==}
dev: false
/chardet/1.5.1:
resolution: {integrity: sha512-0XMOtA52igKDOIfvJZJ6v0+J9yMF3IuYyEa5oFUxBXA01G6mwCNKpul3bgbFf7lmZuqwN/oyg/zQ1cGS7NyJkQ==}
dev: false
/debug/4.3.4:
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.1.2
dev: false
/iconv-lite/0.6.3:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
dependencies:
safer-buffer: 2.1.2
dev: false
/json-stringify-deterministic/1.0.8:
resolution: {integrity: sha512-rkJID3qeigo3VCrEcxX1333fTBBxW89YrdYcZexMnL/WdB8u0zctyG63e/DpahRJyrWCDhh7IQhiR7u2XEDQ4Q==}
engines: {node: '>= 4'}
dev: false
/lodash.defaultsdeep/4.6.1:
resolution: {integrity: sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==}
dev: false
/ms/2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
dev: false
/prettier/2.8.3:
resolution: {integrity: sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==}
engines: {node: '>=10.13.0'}
hasBin: true
dev: true
/safer-buffer/2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
dev: false
/tiny-typed-emitter/2.1.0:
resolution: {integrity: sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==}
dev: false
/typescript/4.9.4:
resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==}
engines: {node: '>=4.2.0'}
hasBin: true
dev: true
git.lumeweb.com/LumeWeb/peer-discovery/abdb430c273301f7652feb8f9026c89a78f58d7a:
resolution: {commit: abdb430c273301f7652feb8f9026c89a78f58d7a, repo: https://git.lumeweb.com/LumeWeb/peer-discovery.git, type: git}
name: '@lumeweb/peer-discovery'
version: 0.1.0
dependencies:
b4a: 1.6.1
dev: false

View File

@ -1,11 +1,10 @@
import type { Peer } from "@lumeweb/peer-discovery"; import type { Peer } from "@lumeweb/libpeerdiscovery";
import { IrcClient } from "@ctrl/irc"; import { IrcClient } from "@ctrl/irc";
import jsonStringify from "json-stringify-deterministic"; import jsonStringify from "json-stringify-deterministic";
import b4a from "b4a"; import { ed25519 } from "@noble/curves/ed25519";
import * as ed from "@noble/ed25519";
import { ripemd160 } from "@noble/hashes/ripemd160"; import { ripemd160 } from "@noble/hashes/ripemd160";
import { sha256 } from "@noble/hashes/sha256"; import { sha256 } from "@noble/hashes/sha256";
import { bytesToHex } from "@noble/hashes/utils"; import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils";
const hash160 = (data: Uint8Array) => ripemd160(sha256(data)); const hash160 = (data: Uint8Array) => ripemd160(sha256(data));
@ -16,12 +15,17 @@ interface SignedPeerResponse extends Peer {
export default async ( export default async (
pubkey: Buffer, pubkey: Buffer,
options = { host: "irc.liberta.casa" } options = { host: "irc.liberta.casa" },
): Promise<boolean | Peer> => { ): Promise<boolean | Peer> => {
let ircPubKey = await ed.getPublicKey(ed.utils.randomPrivateKey()); return {
host: "relay1.lumeweb.com",
port: 8080,
};
/*
let ircPubKey = ed25519.getPublicKey(ed25519.utils.randomPrivateKey());
let client = new IrcClient( let client = new IrcClient(
undefined, undefined as any,
bytesToHex(hash160(ircPubKey)).substring(0, 15), bytesToHex(hash160(ircPubKey)).substring(0, 15),
{ {
host: options.host, host: options.host,
@ -29,7 +33,7 @@ export default async (
secure: true, secure: true,
channels: ["#lumeweb"], channels: ["#lumeweb"],
realName: "lumeweb-client", realName: "lumeweb-client",
} },
); );
client.connect(); client.connect();
@ -38,7 +42,7 @@ export default async (
client.once("join", resolve); client.once("join", resolve);
}); });
client.say("#lumeweb", b4a.toBuffer(pubkey).toString("hex")); client.say("#lumeweb", bytesToHex(pubkey));
return new Promise<Peer>((resolve, reject) => { return new Promise<Peer>((resolve, reject) => {
client.on("pm", async (from: string, text: string) => { client.on("pm", async (from: string, text: string) => {
@ -57,11 +61,11 @@ export default async (
const verifyPayload = jsonStringify(verifyData); const verifyPayload = jsonStringify(verifyData);
if ( if (
!(await ed.verify( !ed25519.verify(
b4a.from(json.signature, "hex"), hexToBytes(json.signature as string),
b4a.from(verifyPayload), utf8ToBytes(verifyPayload),
pubkey pubkey,
)) )
) { ) {
return; return;
} }
@ -69,5 +73,10 @@ export default async (
client.end(); client.end();
resolve({ host: json.host, port: json.port }); resolve({ host: json.host, port: json.port });
}); });
});
setTimeout(() => {
client.end();
reject("irc discovery response timed out");
}, 3000);
});*/
}; };

View File

@ -1,15 +0,0 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"sourceMap": true,
"esModuleInterop": true,
"outDir": "dist",
"declaration": true,
"moduleResolution": "nodenext"
},
"include": ["src"],
"exclude": [
"node_modules"
]
}