This commit is contained in:
Iris Lightshard 2024-04-21 18:02:44 -06:00
commit ecfebf8de6
Signed by: nilix
GPG Key ID: 688407174966CAF3
8 changed files with 2018 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
dist/main.js

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# underBBS
underBBS is a platform-agnostic messaging and social media client
## building
1. `npm install`
2. `npx webpack`

29
dist/index.html vendored Normal file
View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>underBBS</title>
<meta name="viewport" content="width=device-width" />
<link rel="shortcut icon" href="./favicon.png"/>
<link href="./style.css" rel="stylesheet" />
</head>
<body>
<noscript><div id="noscript_container">
JS app lol
</div>
</noscript>
<div id="map"></div>
<div id="err_wrapper" style='display:none'><button id="err_close" onclick="closeErr()">x</button><div id="err_div"></div></div>
<nav>
<ul>
</ul>
</nav>
<main>
<div id="tabbar"></div>
<div id="tabcontent"></div>
</main>
</body>
<script src="./main.js" type="application/javascript"></script>
</html>

5
dist/main.js.LICENSE.txt vendored Normal file
View File

@ -0,0 +1,5 @@
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */

1882
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "underbbs",
"version": "0.0.1",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@nostr-dev-kit/ndk": "^2.7.1"
},
"devDependencies": {
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
}
}

53
src/adapter.js Normal file
View File

@ -0,0 +1,53 @@
import NDK, {NDKPrivateKeySigner} from "@nostr-dev-kit/ndk";
let ndk = null;
function createAdapter() {
let adapter = {
nickname: "",
identity: null,
protocol: null,
};
adatper.init = ()=>{};
adapter.getInbox = ()=>{};
adapter.getFollowers = ()=>{};
adapter.getFollowing = ()=>{};
adapter.publish = ()=>{};
adapter.updateMetadata = ()=>{};
adapter.getMetadata = ()=>{};
return adapter;
}
function toNostrAdapter(adapter, settings) {
adapter.identity = { privkey: settings.privkey };
adapter.init = ()=> {
if (!ndk) {
ndk = new NDK({
signer: new NDKPrivateKeySigner(settings.privatekey),
explicitRelayUrls: [ settings.relays ]
});
ndk.connect();
} else {
ndk.activeUser = new NDKPrivateKeySigner(settings.privatekey);
for (let i of settings.relays) {
ndk.addExplicitRelay(i);
}
}
};
adapter.getInbox = () => {
const sub = ndk.subscribe({ kinds: [1] }); // Get all kind:1s
sub.on("event", (event) => console.log(event.content)); // Show the content
sub.on("eose", () => console.log("All relays have reached the end of the event stream"));
sub.on("close", () => console.log("Subscription closed"));
setTimeout(() => sub.stop(), 10000); // Stop the subscription after 10 seconds
};
return adapter;
}
export default { createAdapter, toNostrAdapter }

21
src/index.js Normal file
View File

@ -0,0 +1,21 @@
import { createAdapter, toNostrAdapter } from "./adapter";
let adapters = [];
function main() {
let settings = localStorage.getItem("settings");
if (settings != null) {
for (let s of settings.adapters) {
switch (s.protocol) {
case "nostr":
let a = toNostrAdapter(createAdapter(), s);
adapters.push(a);
break;
}
}
} else {
console.log("no settings exist for this client");
}
};
main();